@peerbit/stream 4.3.10 → 4.4.0
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/src/index.d.ts +52 -18
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +377 -83
- package/dist/src/index.js.map +1 -1
- package/dist/src/pushable-lanes.d.ts +6 -0
- package/dist/src/pushable-lanes.d.ts.map +1 -1
- package/dist/src/pushable-lanes.js +3 -1
- package/dist/src/pushable-lanes.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +434 -114
- package/src/pushable-lanes.ts +7 -1
package/src/pushable-lanes.ts
CHANGED
|
@@ -70,6 +70,10 @@ export interface Options {
|
|
|
70
70
|
* How many lanes, lane 0 is fastest and will drain before lane 1 is consumed
|
|
71
71
|
*/
|
|
72
72
|
lanes?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Optional hook invoked on every successful push with the value and lane
|
|
75
|
+
*/
|
|
76
|
+
onPush?(value: { byteLength: number }, lane: number): void;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
export interface DoneResult {
|
|
@@ -256,7 +260,9 @@ function _pushable<PushType extends Uint8Array, ValueType, ReturnType>(
|
|
|
256
260
|
return pushable;
|
|
257
261
|
}
|
|
258
262
|
|
|
259
|
-
|
|
263
|
+
const out = bufferNext({ done: false, value }, lane);
|
|
264
|
+
options?.onPush?.(value, lane);
|
|
265
|
+
return out;
|
|
260
266
|
};
|
|
261
267
|
const end = (err?: Error): ReturnType => {
|
|
262
268
|
if (ended) return pushable;
|