@autonomys/asynchronous 1.4.30 → 1.4.32

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './asyncGenerators';
2
2
  export * from './concurrency';
3
+ export * from './streams';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
package/dist/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./asyncGenerators"), exports);
18
18
  __exportStar(require("./concurrency"), exports);
19
+ __exportStar(require("./streams"), exports);
@@ -0,0 +1,3 @@
1
+ import { Readable } from 'stream';
2
+ export declare function forkStream(stream: Readable): Promise<[Readable, Readable]>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streams/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAG9C,wBAAsB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAQhF"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.forkStream = forkStream;
16
+ const stream_1 = require("stream");
17
+ const stream_fork_1 = __importDefault(require("stream-fork"));
18
+ function forkStream(stream) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const passThrough1 = new stream_1.PassThrough();
21
+ const passThrough2 = new stream_1.PassThrough();
22
+ const writable = stream_fork_1.default.fork([passThrough1, passThrough2]);
23
+ stream.pipe(writable);
24
+ return [passThrough1, passThrough2];
25
+ });
26
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@autonomys/asynchronous",
3
3
  "packageManager": "yarn@4.7.0",
4
- "version": "1.4.30",
4
+ "version": "1.4.32",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -22,6 +22,7 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "devDependencies": {
24
24
  "@types/jest": "^29.5.14",
25
+ "@types/stream-fork": "^1",
25
26
  "eslint": "^9.25.1",
26
27
  "interface-store": "^6.0.2",
27
28
  "jest": "^29.7.0",
@@ -29,5 +30,8 @@
29
30
  "ts-jest": "^29.3.1",
30
31
  "typescript": "^5.8.3"
31
32
  },
32
- "gitHead": "80fd427b79a318f8faf0bb7d22fb67d4939ef3d4"
33
+ "gitHead": "d9597f6ddef07c2abd8bba8d6011fdad4877913e",
34
+ "dependencies": {
35
+ "stream-fork": "^1.0.5"
36
+ }
33
37
  }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './asyncGenerators'
2
2
  export * from './concurrency'
3
+ export * from './streams'
@@ -0,0 +1,12 @@
1
+ import { PassThrough, Readable } from 'stream'
2
+ import streamFork from 'stream-fork'
3
+
4
+ export async function forkStream(stream: Readable): Promise<[Readable, Readable]> {
5
+ const passThrough1 = new PassThrough()
6
+ const passThrough2 = new PassThrough()
7
+ const writable = streamFork.fork([passThrough1, passThrough2])
8
+
9
+ stream.pipe(writable)
10
+
11
+ return [passThrough1, passThrough2]
12
+ }