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