Musique/node_modules/async.util.keyiterator/index.js

25 lines
537 B
JavaScript
Raw Normal View History

'use strict';
var _keys = require('async.util.keys');
var isArrayLike = require('async.util.isarraylike');
module.exports = function keyIterator(coll) {
var i = -1;
var len;
var keys;
if (isArrayLike(coll)) {
len = coll.length;
return function next() {
i++;
return i < len ? i : null;
};
} else {
keys = _keys(coll);
len = keys.length;
return function next() {
i++;
return i < len ? keys[i] : null;
};
}
};