@scelar/nodepod 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{child_process-PY34i_6n.js → child_process-4ZrgCVFu.js} +5 -4
- package/dist/{child_process-PY34i_6n.js.map → child_process-4ZrgCVFu.js.map} +1 -1
- package/dist/{child_process-B9qsOKHs.cjs → child_process-Cao4lyrb.cjs} +6 -5
- package/dist/{child_process-B9qsOKHs.cjs.map → child_process-Cao4lyrb.cjs.map} +1 -1
- package/dist/{index-CyhVjVJU.cjs → index-DuYo2yDs.cjs} +597 -138
- package/dist/index-DuYo2yDs.cjs.map +1 -0
- package/dist/{index-D8Hn2kWU.js → index-HkVqijtm.js} +604 -136
- package/dist/index-HkVqijtm.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +88 -88
- package/dist/index.mjs +1 -1
- package/dist/memory-handler.d.ts +57 -57
- package/dist/memory-volume.d.ts +157 -157
- package/dist/packages/installer.d.ts +44 -44
- package/dist/persistence/idb-cache.d.ts +7 -7
- package/dist/polyfills/readline.d.ts +108 -87
- package/dist/script-engine.d.ts +84 -84
- package/dist/sdk/nodepod-process.d.ts +29 -29
- package/dist/sdk/nodepod.d.ts +59 -59
- package/dist/sdk/types.d.ts +64 -64
- package/package.json +97 -97
- package/src/polyfills/child_process.ts +3 -0
- package/src/polyfills/events.ts +16 -2
- package/src/polyfills/readline.ts +593 -71
- package/src/polyfills/stream.ts +45 -0
- package/dist/index-CyhVjVJU.cjs.map +0 -1
- package/dist/index-D8Hn2kWU.js.map +0 -1
package/src/polyfills/stream.ts
CHANGED
|
@@ -1404,9 +1404,41 @@ export const Stream = function Stream(this: any) {
|
|
|
1404
1404
|
Object.setPrototypeOf(Stream.prototype, EventEmitter.prototype);
|
|
1405
1405
|
|
|
1406
1406
|
Stream.prototype.pipe = function pipe(dest: any): any {
|
|
1407
|
+
const src = this;
|
|
1408
|
+
const onData = (chunk: any) => {
|
|
1409
|
+
if (dest.write) dest.write(chunk);
|
|
1410
|
+
};
|
|
1411
|
+
src.on("data", onData);
|
|
1412
|
+
const onEnd = () => {
|
|
1413
|
+
if (dest.end) dest.end();
|
|
1414
|
+
};
|
|
1415
|
+
src.on("end", onEnd);
|
|
1416
|
+
// store for unpipe
|
|
1417
|
+
if (!src._pipeDests) src._pipeDests = [];
|
|
1418
|
+
src._pipeDests.push({ dest, onData, onEnd });
|
|
1407
1419
|
return dest;
|
|
1408
1420
|
};
|
|
1409
1421
|
|
|
1422
|
+
Stream.prototype.unpipe = function unpipe(dest?: any): any {
|
|
1423
|
+
const dests: Array<{ dest: any; onData: Function; onEnd: Function }> =
|
|
1424
|
+
this._pipeDests || [];
|
|
1425
|
+
if (dest) {
|
|
1426
|
+
const idx = dests.findIndex((d: any) => d.dest === dest);
|
|
1427
|
+
if (idx !== -1) {
|
|
1428
|
+
this.removeListener("data", dests[idx].onData as any);
|
|
1429
|
+
this.removeListener("end", dests[idx].onEnd as any);
|
|
1430
|
+
dests.splice(idx, 1);
|
|
1431
|
+
}
|
|
1432
|
+
} else {
|
|
1433
|
+
for (const d of dests) {
|
|
1434
|
+
this.removeListener("data", d.onData as any);
|
|
1435
|
+
this.removeListener("end", d.onEnd as any);
|
|
1436
|
+
}
|
|
1437
|
+
this._pipeDests = [];
|
|
1438
|
+
}
|
|
1439
|
+
return this;
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1410
1442
|
export function addAbortSignal(
|
|
1411
1443
|
signal: AbortSignal,
|
|
1412
1444
|
stream: any,
|
|
@@ -1454,6 +1486,19 @@ export function pipeline(...args: unknown[]): unknown {
|
|
|
1454
1486
|
return streams[0];
|
|
1455
1487
|
}
|
|
1456
1488
|
|
|
1489
|
+
// web ReadableStreams (like fetch response.body) don't have .pipe(), wrap them
|
|
1490
|
+
for (let i = 0; i < streams.length; i++) {
|
|
1491
|
+
const s = streams[i];
|
|
1492
|
+
if (
|
|
1493
|
+
s &&
|
|
1494
|
+
typeof s.getReader === "function" &&
|
|
1495
|
+
typeof s.pipe !== "function" &&
|
|
1496
|
+
typeof s.on !== "function"
|
|
1497
|
+
) {
|
|
1498
|
+
streams[i] = Readable.fromWeb(s);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1457
1502
|
let errorOccurred = false;
|
|
1458
1503
|
const onError = (...errArgs: unknown[]) => {
|
|
1459
1504
|
const err = errArgs[0] as Error;
|