* Create a push stream with optional transforms. * @param {...(Function|object)} args - Transforms, then options (optional) * @returns {{ writer: Writer, readable: AsyncIterable }}
(...args)
| 694 | * @returns {{ writer: Writer, readable: AsyncIterable<Uint8Array[]> }} |
| 695 | */ |
| 696 | function push(...args) { |
| 697 | const { transforms, options } = parseArgs(args); |
| 698 | |
| 699 | const queue = new PushQueue(options); |
| 700 | const writer = new PushWriter(queue); |
| 701 | const rawReadable = createReadable(queue); |
| 702 | |
| 703 | // Apply transforms lazily if provided |
| 704 | let readable; |
| 705 | if (transforms.length > 0) { |
| 706 | if (options.signal) { |
| 707 | readable = pullWithTransforms( |
| 708 | rawReadable, ...transforms, { __proto__: null, signal: options.signal }); |
| 709 | } else { |
| 710 | readable = pullWithTransforms(rawReadable, ...transforms); |
| 711 | } |
| 712 | } else { |
| 713 | readable = rawReadable; |
| 714 | } |
| 715 | |
| 716 | return { __proto__: null, writer, readable }; |
| 717 | } |
| 718 | |
| 719 | module.exports = { |
| 720 | push, |
no test coverage detected
searching dependent graphs…