Files: 856f3c822d3053b57d2045da16a0d9d070e053d7 / sources / values.js
523 bytesRaw
1 | |
2 | var abortCb = require('../util/abort-cb') |
3 | |
4 | module.exports = function values (array, onAbort) { |
5 | if(!array) |
6 | return function (abort, cb) { |
7 | if(abort) return abortCb(cb, abort, onAbort) |
8 | return cb(true) |
9 | } |
10 | if(!Array.isArray(array)) |
11 | array = Object.keys(array).map(function (k) { |
12 | return array[k] |
13 | }) |
14 | var i = 0 |
15 | return function (abort, cb) { |
16 | if(abort) |
17 | return abortCb(cb, abort, onAbort) |
18 | if(i >= array.length) |
19 | cb(true) |
20 | else |
21 | cb(null, array[i++]) |
22 | } |
23 | } |
24 |
Built with git-ssb-web