UNPKG

blue-iterate

Version:

A collection of streams that work well with promises (through, map, reduce). Through2 with promise support

27 lines (26 loc) 980 B
"use strict"; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; Object.defineProperty(exports, "__esModule", { value: true }); async function collect(iterable) { const values = []; try { for (var iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = await iterable_1.next(), !iterable_1_1.done;) { const value = await iterable_1_1.value; values.push(value); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) await _a.call(iterable_1); } finally { if (e_1) throw e_1.error; } } return values; var e_1, _a; } exports.collect = collect;