@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.
@@ -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
- return bufferNext({ done: false, value }, lane);
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;