iter-tools-es
Version:
The iterable toolbox
21 lines (15 loc) • 405 B
JavaScript
const {
ensureIterable
} = require('../../internal/iterable.js');
function __toObject(iterable, proto = Object.prototype) {
const obj = Object.create(proto);
for (const [key, value] of iterable) {
obj[key] = value;
}
return obj;
}
exports.__toObject = __toObject;
function toObject(iterable, proto) {
return __toObject(ensureIterable(iterable), proto);
}
exports.toObject = toObject;