@konker.dev/tiny-utils-fp 0.0.2 → 0.1.1
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/README.md +1 -1
- package/dist/array.d.ts +1 -0
- package/dist/array.d.ts.map +1 -0
- package/dist/array.js +2 -6
- package/dist/array.js.map +1 -1
- package/dist/hash.d.ts +5 -4
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +12 -44
- package/dist/hash.js.map +1 -1
- package/dist/stream/BufferWriteableStream.d.ts +1 -0
- package/dist/stream/BufferWriteableStream.d.ts.map +1 -0
- package/dist/stream/BufferWriteableStream.js +2 -6
- package/dist/stream/BufferWriteableStream.js.map +1 -1
- package/dist/stream/BufferWriteableStream.test.d.ts +1 -0
- package/dist/stream/BufferWriteableStream.test.d.ts.map +1 -0
- package/dist/stream/BufferWriteableStream.test.js +2 -26
- package/dist/stream/BufferWriteableStream.test.js.map +1 -1
- package/dist/stream/ChildProcessStreamPipe.d.ts +1 -0
- package/dist/stream/ChildProcessStreamPipe.d.ts.map +1 -0
- package/dist/stream/ChildProcessStreamPipe.js +7 -11
- package/dist/stream/ChildProcessStreamPipe.js.map +1 -1
- package/dist/stream/ChildProcessStreamPipe.test.d.ts +1 -0
- package/dist/stream/ChildProcessStreamPipe.test.d.ts.map +1 -0
- package/dist/stream/ChildProcessStreamPipe.test.js +26 -51
- package/dist/stream/ChildProcessStreamPipe.test.js.map +1 -1
- package/dist/stream/index.d.ts +5 -4
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +17 -64
- package/dist/stream/index.js.map +1 -1
- package/dist/stream/index.test.d.ts +1 -0
- package/dist/stream/index.test.d.ts.map +1 -0
- package/dist/stream/index.test.js +25 -49
- package/dist/stream/index.test.js.map +1 -1
- package/package.json +61 -44
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ General utility functions for [Node.js](https://nodejs.org/) based on [Effect-TS
|
|
|
4
4
|
|
|
5
5
|
FIXME: test coverage for `src/stream/ChildProcessStreamPipe.ts`
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
[](https://www.npmjs.com/package/@konker.dev/tiny-utils-fp)
|
|
9
9
|
[](https://github.com/konkerdotdev/tiny-utils-fp/actions/workflows/ci.yml)
|
|
10
10
|
[](https://codecov.io/gh/konkerdotdev/tiny-utils-fp)
|
package/dist/array.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAE1D"}
|
package/dist/array.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToUint8Array = stringToUint8Array;
|
|
4
|
-
exports.arrayBufferToString = arrayBufferToString;
|
|
5
|
-
function stringToUint8Array(s) {
|
|
1
|
+
export function stringToUint8Array(s) {
|
|
6
2
|
return new TextEncoder().encode(String(s));
|
|
7
3
|
}
|
|
8
|
-
function arrayBufferToString(a) {
|
|
4
|
+
export function arrayBufferToString(a) {
|
|
9
5
|
return new TextDecoder('utf-8').decode(a);
|
|
10
6
|
}
|
|
11
7
|
//# sourceMappingURL=array.js.map
|
package/dist/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACnD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAc;IAChD,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/hash.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
export declare const md5Hex: (s: string) =>
|
|
3
|
-
export declare const sha256Hex: (s: string) =>
|
|
4
|
-
export declare const sha256HmacHex: (s: string, secret: string) =>
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
export declare const md5Hex: (s: string) => Effect.Effect<string, Error>;
|
|
3
|
+
export declare const sha256Hex: (s: string) => Effect.Effect<string, Error>;
|
|
4
|
+
export declare const sha256HmacHex: (s: string, secret: string) => Effect.Effect<string, Error>;
|
|
5
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,MAAM,MAAO,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAI1D,CAAC;AAEL,eAAO,MAAM,SAAS,MAAO,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAI7D,CAAC;AAEL,eAAO,MAAM,aAAa,MAAO,MAAM,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAIjF,CAAC"}
|
package/dist/hash.js
CHANGED
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { toError } from '@konker.dev/tiny-error-fp/lib';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
export const md5Hex = (s) => Effect.try({
|
|
5
|
+
try: () => crypto.createHash('md5').update(s).digest('hex'),
|
|
6
|
+
catch: toError,
|
|
17
7
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.sha256HmacHex = exports.sha256Hex = exports.md5Hex = void 0;
|
|
30
|
-
const P = __importStar(require("@konker.dev/effect-ts-prelude"));
|
|
31
|
-
const lib_1 = require("@konker.dev/tiny-error-fp/dist/lib");
|
|
32
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
33
|
-
const md5Hex = (s) => P.Effect.try({
|
|
34
|
-
try: () => node_crypto_1.default.createHash('md5').update(s).digest('hex'),
|
|
35
|
-
catch: lib_1.toError,
|
|
8
|
+
export const sha256Hex = (s) => Effect.try({
|
|
9
|
+
try: () => crypto.createHash('sha256').update(s).digest('hex'),
|
|
10
|
+
catch: toError,
|
|
36
11
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
catch: lib_1.toError,
|
|
12
|
+
export const sha256HmacHex = (s, secret) => Effect.try({
|
|
13
|
+
try: () => crypto.createHmac('sha256', secret).update(s).digest('hex'),
|
|
14
|
+
catch: toError,
|
|
41
15
|
});
|
|
42
|
-
exports.sha256Hex = sha256Hex;
|
|
43
|
-
const sha256HmacHex = (s, secret) => P.Effect.try({
|
|
44
|
-
try: () => node_crypto_1.default.createHmac('sha256', secret).update(s).digest('hex'),
|
|
45
|
-
catch: lib_1.toError,
|
|
46
|
-
});
|
|
47
|
-
exports.sha256HmacHex = sha256HmacHex;
|
|
48
16
|
//# sourceMappingURL=hash.js.map
|
package/dist/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAgC,EAAE,CAChE,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3D,KAAK,EAAE,OAAO;CACf,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAgC,EAAE,CACnE,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC9D,KAAK,EAAE,OAAO;CACf,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,MAAc,EAAgC,EAAE,CACvF,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IACtE,KAAK,EAAE,OAAO;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferWriteableStream.d.ts","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;IACjD,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;;IAO1B,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAKxG;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferWriteableStream = void 0;
|
|
4
1
|
/* eslint-disable fp/no-class,fp/no-unused-expression,fp/no-nil,fp/no-mutating-methods,fp/no-this,fp/no-mutation */
|
|
5
|
-
|
|
2
|
+
import { Writable } from 'node:stream';
|
|
6
3
|
/**
|
|
7
4
|
* Simplistic implementation of a Writeable which stores the data in a Buffer
|
|
8
5
|
* The contents can be extracted as a Buffer or as a UTF-8 string.
|
|
@@ -11,7 +8,7 @@ const node_stream_1 = require("node:stream");
|
|
|
11
8
|
* needed for production use, consider a more comprehensive/optimized
|
|
12
9
|
* implementation such as: https://github.com/samcday/node-stream-buffer
|
|
13
10
|
*/
|
|
14
|
-
class BufferWriteableStream extends
|
|
11
|
+
export class BufferWriteableStream extends Writable {
|
|
15
12
|
bufferList;
|
|
16
13
|
constructor() {
|
|
17
14
|
super();
|
|
@@ -40,5 +37,4 @@ class BufferWriteableStream extends node_stream_1.Writable {
|
|
|
40
37
|
return this.buffer.toString('utf8');
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.BufferWriteableStream = BufferWriteableStream;
|
|
44
40
|
//# sourceMappingURL=BufferWriteableStream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferWriteableStream.js","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BufferWriteableStream.js","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IACxC,UAAU,CAAgB;IAEnC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAEQ,MAAM,CAAC,KAAY,EAAE,SAAyB,EAAE,QAAwC;QAC/F,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,QAAQ,EAAE,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferWriteableStream.test.d.ts","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const unit = __importStar(require("./BufferWriteableStream"));
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import * as unit from './BufferWriteableStream.js';
|
|
27
3
|
describe('BufferWriteableStream', () => {
|
|
28
4
|
const TEST_STRING_1 = 'hoi noi broin coi';
|
|
29
5
|
const TEST_STRING_2 = 'three blind mice';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferWriteableStream.test.js","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BufferWriteableStream.test.js","sourceRoot":"","sources":["../../src/stream/BufferWriteableStream.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC1C,MAAM,aAAa,GAAG,kBAAkB,CAAC;IAEzC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,EAAE,CAAC;QAEb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,EAAE,CAAC;QAEb,MAAM,CAAC,MAAM,CAAC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AAK,CAAC,MAAM,CAAC,CAExB;IAED,IAAI,IAAI,IAAI;IAwBZ,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;CAKjC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const node_stream_1 = require("node:stream");
|
|
6
|
-
const types_1 = require("node:util/types");
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { Stream } from 'node:stream';
|
|
3
|
+
import { isNativeError } from 'node:util/types';
|
|
7
4
|
/*
|
|
8
5
|
* See: https://www.jameskerr.blog/posts/pipe-nodejs-readable-stream-into-child-process/
|
|
9
6
|
* See: https://www.npmjs.com/package/imagemagick-stream
|
|
10
7
|
*/
|
|
11
|
-
class ChildProcessStreamPipe extends
|
|
8
|
+
export class ChildProcessStreamPipe extends Stream.Transform {
|
|
12
9
|
cmd;
|
|
13
10
|
_args;
|
|
14
11
|
_input;
|
|
@@ -68,11 +65,11 @@ class ChildProcessStreamPipe extends node_stream_1.Stream.Transform {
|
|
|
68
65
|
exec() {
|
|
69
66
|
const onError = this.onError.bind(this);
|
|
70
67
|
try {
|
|
71
|
-
this._childProcess =
|
|
68
|
+
this._childProcess = spawn(this.cmd, [this._input, ...this.args, this._output]);
|
|
72
69
|
this._childProcess.on('error', onError);
|
|
73
70
|
this._childProcess.stdout.on('data', (data) => this.push(data));
|
|
74
71
|
this._childProcess.stdin?.on('error', (e) => {
|
|
75
|
-
if (e.code === 'EPIPE') {
|
|
72
|
+
if (!!e && typeof e === 'object' && 'code' in e && e.code === 'EPIPE') {
|
|
76
73
|
this.emit('end');
|
|
77
74
|
}
|
|
78
75
|
else {
|
|
@@ -88,10 +85,9 @@ class ChildProcessStreamPipe extends node_stream_1.Stream.Transform {
|
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
onError(err) {
|
|
91
|
-
const errorErr =
|
|
88
|
+
const errorErr = isNativeError(err) ? err : new Error(String(err));
|
|
92
89
|
this.destroy(errorErr);
|
|
93
90
|
this.emit('end');
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
|
-
exports.ChildProcessStreamPipe = ChildProcessStreamPipe;
|
|
97
93
|
//# sourceMappingURL=ChildProcessStreamPipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChildProcessStreamPipe.js","sourceRoot":"","sources":["../../src/stream/ChildProcessStreamPipe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChildProcessStreamPipe.js","sourceRoot":"","sources":["../../src/stream/ChildProcessStreamPipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,SAAS;IACjD,GAAG,CAAS;IACZ,KAAK,CAAgB;IAC9B,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,YAAY,CAAU;IACtB,aAAa,CAA6C;IAE1D,YAAY,GAAW,EAAE,OAAsB,EAAE;QAC/C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEQ,UAAU,CAAC,KAAc,EAAE,QAAwB,EAAE,QAA2B;QACvF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YACxE,OAAO,CAAC,QA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C;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAwB;QAC9B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChildProcessStreamPipe.test.d.ts","sourceRoot":"","sources":["../../src/stream/ChildProcessStreamPipe.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
/* eslint-disable fp/no-mutating-methods,fp/no-throw */
|
|
27
|
-
const childProcess = __importStar(require("node:child_process"));
|
|
28
|
-
const node_stream_1 = require("node:stream");
|
|
29
|
-
const BufferWriteableStream_1 = require("./BufferWriteableStream");
|
|
30
|
-
const unit = __importStar(require("./ChildProcessStreamPipe"));
|
|
31
|
-
const index_1 = require("./index");
|
|
1
|
+
import * as childProcess from 'node:child_process';
|
|
2
|
+
import { PassThrough, Readable } from 'node:stream';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { BufferWriteableStream } from './BufferWriteableStream.js';
|
|
5
|
+
import * as unit from './ChildProcessStreamPipe.js';
|
|
6
|
+
import { waitForWriteStreamPromise } from './index.js';
|
|
32
7
|
describe('ChildProcessStreamPipe', () => {
|
|
33
8
|
const TEST_S = 'hoi noi broin coi';
|
|
34
9
|
it('should formulate args as expected', () => {
|
|
@@ -38,57 +13,57 @@ describe('ChildProcessStreamPipe', () => {
|
|
|
38
13
|
});
|
|
39
14
|
it('should work as expected in the success case', async () => {
|
|
40
15
|
const actual = new unit.ChildProcessStreamPipe('sed', ['-e', 's/\\(.*\\)/\\U\\1/']).input('-').output('-');
|
|
41
|
-
const inStream =
|
|
42
|
-
const outStream = new
|
|
16
|
+
const inStream = Readable.from(TEST_S);
|
|
17
|
+
const outStream = new BufferWriteableStream();
|
|
43
18
|
inStream.pipe(actual).pipe(outStream);
|
|
44
|
-
await
|
|
45
|
-
actual._flush(
|
|
19
|
+
await waitForWriteStreamPromise(outStream);
|
|
20
|
+
actual._flush(vi.fn());
|
|
46
21
|
expect(outStream.string).toEqual('HOI NOI BROIN COI');
|
|
47
22
|
});
|
|
48
23
|
// Test fails due to Unhandled error
|
|
49
24
|
// FIXME: Needs further work
|
|
50
|
-
|
|
25
|
+
it.skip('should work as expected with a stdin error', async () => {
|
|
51
26
|
const actual = new unit.ChildProcessStreamPipe('sed', ['-e', 's/\\(.*\\)/\\U\\1/']).input('-').output('-');
|
|
52
|
-
const inStream =
|
|
53
|
-
const outStream = new
|
|
27
|
+
const inStream = Readable.from(TEST_S);
|
|
28
|
+
const outStream = new BufferWriteableStream();
|
|
54
29
|
inStream.pipe(actual).pipe(outStream);
|
|
55
30
|
actual._childProcess?.stdin.emit('error', new Error('BOOM!'));
|
|
56
|
-
await
|
|
31
|
+
await waitForWriteStreamPromise(outStream);
|
|
57
32
|
expect(outStream.string).toEqual('');
|
|
58
33
|
});
|
|
59
34
|
it('should work as expected with a stdin EPIPE error', async () => {
|
|
60
35
|
const actual = new unit.ChildProcessStreamPipe('sed', ['-e', 's/\\(.*\\)/\\U\\1/']).input('-').output('-');
|
|
61
|
-
const inStream =
|
|
62
|
-
const outStream = new
|
|
36
|
+
const inStream = Readable.from(TEST_S);
|
|
37
|
+
const outStream = new BufferWriteableStream();
|
|
63
38
|
inStream.pipe(actual).pipe(outStream);
|
|
64
39
|
actual._childProcess?.stdin.emit('error', { code: 'EPIPE' });
|
|
65
|
-
await
|
|
40
|
+
await waitForWriteStreamPromise(outStream);
|
|
66
41
|
expect(outStream.string).toEqual('');
|
|
67
42
|
});
|
|
68
43
|
// Test fails with: TypeError: Cannot redefine property: spawn
|
|
69
44
|
// FIXME: Needs more work
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
it.skip('should work as expected in error case', () => {
|
|
46
|
+
vi.spyOn(childProcess, 'spawn').mockImplementationOnce(() => {
|
|
72
47
|
throw new Error('BOOM!');
|
|
73
48
|
});
|
|
74
|
-
const inStream =
|
|
75
|
-
const outStream = new
|
|
49
|
+
const inStream = Readable.from(TEST_S);
|
|
50
|
+
const outStream = new PassThrough();
|
|
76
51
|
const actual = new unit.ChildProcessStreamPipe('cat', ['/tmp/LICENSE']);
|
|
77
52
|
inStream.pipe(actual).pipe(outStream);
|
|
78
53
|
expect(() => {
|
|
79
|
-
return
|
|
54
|
+
return waitForWriteStreamPromise(outStream);
|
|
80
55
|
}).toBeDefined();
|
|
81
56
|
});
|
|
82
57
|
// Causes Unhandled error, but still passes.
|
|
83
58
|
// Plus is not really a proper test for errors due to tricky stream stuff
|
|
84
59
|
// FIXME: Needs further work
|
|
85
|
-
|
|
86
|
-
const inStream =
|
|
87
|
-
const outStream = new
|
|
60
|
+
it.skip('should work as expected in error case', () => {
|
|
61
|
+
const inStream = Readable.from(TEST_S);
|
|
62
|
+
const outStream = new PassThrough();
|
|
88
63
|
const actual = new unit.ChildProcessStreamPipe('cat', ['/tmp/doesnotexist']);
|
|
89
64
|
inStream.pipe(actual).pipe(outStream);
|
|
90
65
|
expect(() => {
|
|
91
|
-
return
|
|
66
|
+
return waitForWriteStreamPromise(outStream);
|
|
92
67
|
}).toBeDefined();
|
|
93
68
|
});
|
|
94
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChildProcessStreamPipe.test.js","sourceRoot":"","sources":["../../src/stream/ChildProcessStreamPipe.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChildProcessStreamPipe.test.js","sourceRoot":"","sources":["../../src/stream/ChildProcessStreamPipe.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,MAAM,MAAM,GAAG,mBAA4B,CAAC;IAE5C,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,EAAE,CAAC,CAA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I,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACxE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEtC,MAAM,CAAC,GAAG,EAAE;YACV,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,4CAA4C;IAC5C,yEAAyE;IACzE,4BAA4B;IAC5B,EAAE,CAAC,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC7E,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEtC,MAAM,CAAC,GAAG,EAAE;YACV,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/stream/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as P from '@konker.dev/effect-ts-prelude';
|
|
2
1
|
import type { Readable, Writable } from 'node:stream';
|
|
3
2
|
import type { ReadableStream } from 'node:stream/web';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
4
|
/**
|
|
5
5
|
* Consume a readStream
|
|
6
6
|
* @param readStream
|
|
7
7
|
*/
|
|
8
|
-
export declare function readStreamToBuffer(readStream: Readable | ReadableStream):
|
|
8
|
+
export declare function readStreamToBuffer(readStream: Readable | ReadableStream): Effect.Effect<Uint8Array, Error>;
|
|
9
9
|
/**
|
|
10
10
|
* Wait for a writable stream to finish
|
|
11
11
|
*/
|
|
@@ -13,8 +13,9 @@ export declare function waitForWriteStreamPromise(writeStream: Writable): Promis
|
|
|
13
13
|
/**
|
|
14
14
|
* Wait for a writable stream to finish
|
|
15
15
|
*/
|
|
16
|
-
export declare function waitForWriteStream(writeStream: Writable):
|
|
16
|
+
export declare function waitForWriteStream(writeStream: Writable): Effect.Effect<void, Error>;
|
|
17
17
|
/**
|
|
18
18
|
* Wait for a readable stream to fully pipe to a write-stream
|
|
19
19
|
*/
|
|
20
|
-
export declare function waitForStreamPipe(readStream: Readable, writeStream: Writable):
|
|
20
|
+
export declare function waitForStreamPipe(readStream: Readable, writeStream: Writable): Effect.Effect<number, Error>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stream/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAc1G;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CASpF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAiB3G"}
|
package/dist/stream/index.js
CHANGED
|
@@ -1,110 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.readStreamToBuffer = readStreamToBuffer;
|
|
27
|
-
exports.waitForWriteStreamPromise = waitForWriteStreamPromise;
|
|
28
|
-
exports.waitForWriteStream = waitForWriteStream;
|
|
29
|
-
exports.waitForStreamPipe = waitForStreamPipe;
|
|
30
|
-
const P = __importStar(require("@konker.dev/effect-ts-prelude"));
|
|
31
|
-
const effect_ts_prelude_1 = require("@konker.dev/effect-ts-prelude");
|
|
32
|
-
const array_1 = require("../array");
|
|
1
|
+
import { toError } from '@konker.dev/tiny-error-fp/lib';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { stringToUint8Array } from '../array.js';
|
|
33
4
|
/**
|
|
34
5
|
* Consume a readStream
|
|
35
6
|
* @param readStream
|
|
36
7
|
*/
|
|
37
|
-
function readStreamToBuffer(readStream) {
|
|
38
|
-
return
|
|
8
|
+
export function readStreamToBuffer(readStream) {
|
|
9
|
+
return Effect.tryPromise({
|
|
39
10
|
try: async () => {
|
|
40
11
|
const chunks = [];
|
|
41
|
-
//
|
|
42
|
-
// eslint-disable-next-line fp/no-loops,fp/no-nil
|
|
12
|
+
// eslint-disable-next-line fp/no-loops
|
|
43
13
|
for await (const chunk of readStream) {
|
|
44
|
-
|
|
45
|
-
chunks.push(typeof chunk === 'string' ? (0, array_1.stringToUint8Array)(chunk) : new Uint8Array(chunk));
|
|
14
|
+
chunks.push(typeof chunk === 'string' ? stringToUint8Array(chunk) : new Uint8Array(chunk));
|
|
46
15
|
}
|
|
47
16
|
// Merge chunks
|
|
48
17
|
return chunks.reduce((acc, val) => new Uint8Array([...acc, ...val]), new Uint8Array());
|
|
49
18
|
},
|
|
50
|
-
catch:
|
|
19
|
+
catch: toError,
|
|
51
20
|
});
|
|
52
21
|
}
|
|
53
22
|
/**
|
|
54
23
|
* Wait for a writable stream to finish
|
|
55
24
|
*/
|
|
56
|
-
function waitForWriteStreamPromise(writeStream) {
|
|
57
|
-
// eslint-disable-next-line fp/no-nil
|
|
25
|
+
export function waitForWriteStreamPromise(writeStream) {
|
|
58
26
|
return new Promise((resolve, reject) => {
|
|
59
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
60
27
|
writeStream.on('finish', resolve);
|
|
61
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
62
28
|
writeStream.on('error', reject);
|
|
63
29
|
});
|
|
64
30
|
}
|
|
65
31
|
/**
|
|
66
32
|
* Wait for a writable stream to finish
|
|
67
33
|
*/
|
|
68
|
-
function waitForWriteStream(writeStream) {
|
|
69
|
-
return
|
|
70
|
-
try: () =>
|
|
71
|
-
// eslint-disable-next-line fp/no-nil
|
|
72
|
-
new Promise((resolve, reject) => {
|
|
73
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
34
|
+
export function waitForWriteStream(writeStream) {
|
|
35
|
+
return Effect.tryPromise({
|
|
36
|
+
try: () => new Promise((resolve, reject) => {
|
|
74
37
|
writeStream.on('finish', resolve);
|
|
75
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
76
38
|
writeStream.on('error', reject);
|
|
77
39
|
}),
|
|
78
|
-
catch:
|
|
40
|
+
catch: toError,
|
|
79
41
|
});
|
|
80
42
|
}
|
|
81
43
|
/**
|
|
82
44
|
* Wait for a readable stream to fully pipe to a write-stream
|
|
83
45
|
*/
|
|
84
|
-
function waitForStreamPipe(readStream, writeStream) {
|
|
85
|
-
return
|
|
86
|
-
try: () =>
|
|
87
|
-
// eslint-disable-next-line fp/no-nil
|
|
88
|
-
new Promise((resolve, reject) => {
|
|
46
|
+
export function waitForStreamPipe(readStream, writeStream) {
|
|
47
|
+
return Effect.tryPromise({
|
|
48
|
+
try: () => new Promise((resolve, reject) => {
|
|
89
49
|
// eslint-disable-next-line fp/no-let
|
|
90
50
|
let size = 0;
|
|
91
|
-
// eslint-disable-next-line fp/no-unused-expression,fp/no-nil
|
|
92
51
|
readStream.on('data', (data) => {
|
|
93
|
-
// eslint-disable-next-line fp/no-mutation
|
|
94
52
|
size = size + data.length;
|
|
95
53
|
});
|
|
96
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
97
54
|
readStream.on('error', reject);
|
|
98
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
99
55
|
writeStream.on('finish', () => resolve(size));
|
|
100
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
101
56
|
writeStream.on('error', reject);
|
|
102
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
103
57
|
readStream.pipe(writeStream);
|
|
104
|
-
// eslint-disable-next-line fp/no-unused-expression
|
|
105
58
|
readStream.resume();
|
|
106
59
|
}),
|
|
107
|
-
catch:
|
|
60
|
+
catch: toError,
|
|
108
61
|
});
|
|
109
62
|
}
|
|
110
63
|
//# sourceMappingURL=index.js.map
|
package/dist/stream/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stream/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stream/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC;IACtE,OAAO,MAAM,CAAC,UAAU,CAAC;QACvB,GAAG,EAAE,KAAK,IAAI,EAAE;YACd,MAAM,MAAM,GAAsB,EAAE,CAAC;YACrC,uCAAuC;YACvC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7F,CAAC;YAED,eAAe;YACf,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,IAAI,U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AAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9C,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7B,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC,CAAC;QACJ,KAAK,EAAE,OAAO;KACf,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/stream/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const P = __importStar(require("@konker.dev/effect-ts-prelude"));
|
|
27
|
-
const node_stream_1 = require("node:stream");
|
|
28
|
-
const array_1 = require("../array");
|
|
29
|
-
const BufferWriteableStream_1 = require("./BufferWriteableStream");
|
|
30
|
-
const unit = __importStar(require("./index"));
|
|
1
|
+
import { PassThrough, Readable } from 'node:stream';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { arrayBufferToString } from '../array.js';
|
|
5
|
+
import { BufferWriteableStream } from './BufferWriteableStream.js';
|
|
6
|
+
import * as unit from './index.js';
|
|
31
7
|
describe('stream utils', () => {
|
|
32
8
|
describe('readStreamToBuffer', () => {
|
|
33
9
|
it('should resolve as expected', async () => {
|
|
34
|
-
const readStream =
|
|
35
|
-
const data = await
|
|
36
|
-
expect(
|
|
10
|
+
const readStream = Readable.from('konker');
|
|
11
|
+
const data = await Effect.runPromise(unit.readStreamToBuffer(readStream));
|
|
12
|
+
expect(arrayBufferToString(data)).toEqual('konker');
|
|
37
13
|
});
|
|
38
14
|
it('should resolve as expected', async () => {
|
|
39
|
-
const readStream =
|
|
40
|
-
const data = await
|
|
41
|
-
expect(
|
|
15
|
+
const readStream = Readable.from(Buffer.from('konker'));
|
|
16
|
+
const data = await Effect.runPromise(unit.readStreamToBuffer(readStream));
|
|
17
|
+
expect(arrayBufferToString(data)).toEqual('konker');
|
|
42
18
|
});
|
|
43
19
|
it('should reject as expected', async () => {
|
|
44
|
-
const readStream =
|
|
20
|
+
const readStream = Readable.from('konker');
|
|
45
21
|
readStream.on('data', () => {
|
|
46
22
|
readStream.emit('error', new Error('Boom!'));
|
|
47
23
|
});
|
|
48
|
-
await expect(
|
|
24
|
+
await expect(Effect.runPromise(unit.readStreamToBuffer(readStream))).rejects.toThrow('Boom!');
|
|
49
25
|
});
|
|
50
26
|
});
|
|
51
27
|
describe('waitForWriteStreamPromise', () => {
|
|
52
28
|
it('should work as expected', async () => {
|
|
53
|
-
const readStream =
|
|
54
|
-
const writeStream = new
|
|
29
|
+
const readStream = Readable.from('konker');
|
|
30
|
+
const writeStream = new BufferWriteableStream();
|
|
55
31
|
readStream.pipe(writeStream);
|
|
56
32
|
await unit.waitForWriteStreamPromise(writeStream);
|
|
57
33
|
expect(writeStream.string).toEqual('konker');
|
|
@@ -59,27 +35,27 @@ describe('stream utils', () => {
|
|
|
59
35
|
});
|
|
60
36
|
describe('waitForWriteStream', () => {
|
|
61
37
|
it('should work as expected', async () => {
|
|
62
|
-
const readStream =
|
|
63
|
-
const writeStream = new
|
|
38
|
+
const readStream = Readable.from('konker');
|
|
39
|
+
const writeStream = new BufferWriteableStream();
|
|
64
40
|
readStream.pipe(writeStream);
|
|
65
|
-
await
|
|
41
|
+
await Effect.runPromise(unit.waitForWriteStream(writeStream));
|
|
66
42
|
expect(writeStream.string).toEqual('konker');
|
|
67
43
|
});
|
|
68
44
|
});
|
|
69
45
|
describe('waitForStreamPipe', () => {
|
|
70
46
|
it('should resolve as expected', async () => {
|
|
71
|
-
const readStream =
|
|
72
|
-
const writeStream = new
|
|
73
|
-
const data = await
|
|
47
|
+
const readStream = Readable.from('konker');
|
|
48
|
+
const writeStream = new PassThrough();
|
|
49
|
+
const data = await Effect.runPromise(unit.waitForStreamPipe(readStream, writeStream));
|
|
74
50
|
expect(data).toEqual(6);
|
|
75
51
|
});
|
|
76
52
|
it('should reject as expected', async () => {
|
|
77
|
-
const readStream =
|
|
78
|
-
const writeStream = new
|
|
53
|
+
const readStream = Readable.from('konker');
|
|
54
|
+
const writeStream = new PassThrough();
|
|
79
55
|
writeStream.on('data', () => {
|
|
80
56
|
writeStream.emit('error', new Error('Boom!'));
|
|
81
57
|
});
|
|
82
|
-
await expect(
|
|
58
|
+
await expect(Effect.runPromise(unit.waitForStreamPipe(readStream, writeStream))).rejects.toThrow('Boom!');
|
|
83
59
|
});
|
|
84
60
|
});
|
|
85
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/stream/index.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/stream/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,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markus <mail@konker.dev>",
|
|
5
|
-
"description": "General utility functions for Node.js TypeScript projects based on Effect-ts",
|
|
6
6
|
"license": "ISC",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"dist/**/*",
|
|
10
|
-
"!dist/**/*.test.*"
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/konkerdotdev/tiny-utils-fp"
|
|
15
|
-
},
|
|
7
|
+
"description": "General utility functions for Node.js TypeScript projects based on Effect-ts",
|
|
8
|
+
"homepage": "https://konker.dev/",
|
|
16
9
|
"keywords": [
|
|
17
10
|
"node",
|
|
18
|
-
"
|
|
11
|
+
"utils",
|
|
19
12
|
"typescript",
|
|
20
13
|
"functional-programming",
|
|
21
14
|
"effect-ts"
|
|
22
15
|
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/konker.dev/packages/tiny-utils-fp"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./stream/BufferWriteableStream": {
|
|
23
|
+
"types": "./dist/stream/BufferWriteableStream.d.ts",
|
|
24
|
+
"import": "./dist/stream/BufferWriteableStream.js"
|
|
25
|
+
},
|
|
26
|
+
"./stream/ChildProcessStreamPipe": {
|
|
27
|
+
"types": "./dist/stream/ChildProcessStreamPipe.d.ts",
|
|
28
|
+
"import": "./dist/stream/ChildProcessStreamPipe.js"
|
|
29
|
+
},
|
|
30
|
+
"./stream": {
|
|
31
|
+
"types": "./dist/stream/index.d.ts",
|
|
32
|
+
"import": "./dist/stream/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./array": {
|
|
35
|
+
"types": "./dist/array.d.ts",
|
|
36
|
+
"import": "./dist/array.js"
|
|
37
|
+
},
|
|
38
|
+
"./hash": {
|
|
39
|
+
"types": "./dist/hash.d.ts",
|
|
40
|
+
"import": "./dist/hash.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist/**/*",
|
|
45
|
+
"!dist/**/*.test.*"
|
|
46
|
+
],
|
|
47
|
+
"main": "dist/index.js",
|
|
23
48
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"@konker.dev/
|
|
26
|
-
"@konker.dev/tiny-error-fp": "^0.0.7",
|
|
27
|
-
"effect": "^3.5.3"
|
|
49
|
+
"effect": "^3.11.3",
|
|
50
|
+
"@konker.dev/tiny-error-fp": "0.1.1"
|
|
28
51
|
},
|
|
29
52
|
"devDependencies": {
|
|
53
|
+
"@arethetypeswrong/cli": "^0.17.1",
|
|
30
54
|
"@effect/language-service": "^0.1.0",
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"eslint": "^
|
|
37
|
-
"eslint-config-prettier": "^9.1.0",
|
|
38
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
39
|
-
"eslint-plugin-deprecation": "^2.0.0",
|
|
55
|
+
"@eslint/compat": "^1.2.4",
|
|
56
|
+
"@eslint/js": "^9.17.0",
|
|
57
|
+
"@konker.dev/common-config": "^0.1.0",
|
|
58
|
+
"@types/node": "^20.17.10",
|
|
59
|
+
"@vitest/coverage-istanbul": "^2.1.8",
|
|
60
|
+
"eslint": "^9.17.0",
|
|
40
61
|
"eslint-plugin-fp": "^2.3.0",
|
|
41
|
-
"eslint-plugin-
|
|
42
|
-
"eslint-plugin-json": "^3.1.0",
|
|
43
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
62
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
44
63
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
45
64
|
"eslint-plugin-sort-destructure-keys": "^1.6.0",
|
|
46
|
-
"gulp": "^4.0.2",
|
|
47
|
-
"husky": "^9.0.11",
|
|
48
|
-
"jest": "^29.7.0",
|
|
49
65
|
"leasot": "^13.3.0",
|
|
50
66
|
"madge": "^6.1.0",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
67
|
+
"prettier": "^3.4.2",
|
|
68
|
+
"tsx": "^4.19.2",
|
|
69
|
+
"type-coverage": "^2.29.7",
|
|
70
|
+
"typescript": "^5.7.2",
|
|
71
|
+
"typescript-eslint": "^8.18.0",
|
|
72
|
+
"vitest": "^2.1.8"
|
|
57
73
|
},
|
|
58
|
-
"staticFiles": [],
|
|
59
74
|
"scripts": {
|
|
60
|
-
"test": "
|
|
75
|
+
"test": "vitest run --coverage",
|
|
61
76
|
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
|
|
62
77
|
"typecheck": "tsc --noEmit",
|
|
63
|
-
"build": "pnpm run clean && tsc
|
|
64
|
-
"type-coverage-check": "type-coverage --detail --at-least 100 --ignore-files src/
|
|
65
|
-
"circular-check": "madge --extensions ts --circular --no-color --no-spinner --warning
|
|
78
|
+
"build": "pnpm run clean && tsc",
|
|
79
|
+
"type-coverage-check": "type-coverage --detail --at-least 100 --ignore-files src/index.test.ts --ignore-files src/stream/index.ts",
|
|
80
|
+
"circular-check": "madge --extensions ts --circular --no-color --no-spinner --warning src",
|
|
66
81
|
"eslint-check": "eslint --max-warnings=0 '**/*.{ts,js,json}'",
|
|
67
|
-
"fixme-check": "leasot --exit-nicely --skip-unsupported --ignore node_modules src",
|
|
68
82
|
"eslint-fix": "npx eslint --fix||true",
|
|
83
|
+
"generated-exports-check": "npx --package=@konker.dev/common-config generate-exports-verify packages/tiny-utils-fp",
|
|
84
|
+
"exports-check": "attw --pack . --ignore-rules=cjs-resolves-to-esm --profile=node16",
|
|
85
|
+
"fixme-check": "leasot --exit-nicely --skip-unsupported src",
|
|
69
86
|
"prettier-check": "npx prettier --check --ignore-path .gitignore --ignore-path .prettierignore '**/*.{css,html,js,ts,json,md,yaml,yml}'",
|
|
70
87
|
"prettier-fix": "pnpm run prettier-check --write",
|
|
71
88
|
"lint-check": "pnpm run eslint-check && pnpm run prettier-check && pnpm run circular-check && pnpm run fixme-check",
|
|
72
89
|
"lint-fix": "pnpm run eslint-fix && pnpm run prettier-fix",
|
|
73
90
|
"pre-push": "pnpm run lint-check && pnpm run typecheck",
|
|
74
|
-
"ci": "pnpm run lint-check && pnpm run typecheck && pnpm run type-coverage-check && pnpm run test && pnpm run build && pnpm run fixme-check",
|
|
91
|
+
"ci": "pnpm run lint-check && pnpm run typecheck && pnpm run type-coverage-check && pnpm run test && pnpm run build && pnpm run generated-exports-check && pnpm run exports-check && pnpm run fixme-check",
|
|
75
92
|
"cd": "pnpm run build && pnpm publish --access public"
|
|
76
93
|
}
|
|
77
94
|
}
|