1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.readableMap = void 0;
|
4 | const index_1 = require("../../index");
|
5 | function readableMap(readable, mapper) {
|
6 | const out = (0, index_1.readableCreate)();
|
7 | void (async () => {
|
8 | try {
|
9 | let index = 0;
|
10 | for await (const item of readable) {
|
11 | const v = await mapper(item, index++);
|
12 | out.push(v);
|
13 | }
|
14 |
|
15 | out.push(null);
|
16 | }
|
17 | catch (err) {
|
18 | console.error(err);
|
19 | out.emit('error', err);
|
20 | }
|
21 | })();
|
22 | return out;
|
23 | }
|
24 | exports.readableMap = readableMap;
|