MCPcopy Index your code
hub / github.com/nodejs/node / share

Function share

lib/internal/streams/iter/share.js:651–680  ·  view source on GitHub ↗
(source, options = { __proto__: null })

Source from the content-addressed store, hash-verified

649// =============================================================================
650
651function share(source, options = { __proto__: null }) {
652 // Normalize source via from() - accepts strings, ArrayBuffers, protocols, etc.
653 const normalized = from(source);
654 validateObject(options, 'options');
655 const {
656 highWaterMark = kMultiConsumerDefaultHWM,
657 backpressure = 'strict',
658 signal,
659 } = options;
660 validateInteger(highWaterMark, 'options.highWaterMark');
661 validateBackpressure(backpressure);
662 if (signal !== undefined) {
663 validateAbortSignal(signal, 'options.signal');
664 }
665
666 const opts = {
667 __proto__: null,
668 highWaterMark: clampHWM(highWaterMark),
669 backpressure,
670 signal,
671 };
672
673 const shareImpl = new ShareImpl(normalized, opts);
674
675 if (signal) {
676 onShareCancel(shareImpl, signal);
677 }
678
679 return shareImpl;
680}
681
682function shareSync(source, options = { __proto__: null }) {
683 // Normalize source via fromSync() - accepts strings, ArrayBuffers, protocols, etc.

Callers 15

fromFunction · 0.85
mainFunction · 0.85
[shareProtocol]Function · 0.85
testShareDisposeFunction · 0.85
testAsyncIteratorThrowFunction · 0.85
testBasicShareFunction · 0.85
testShareConsumerCountFunction · 0.85
testShareCancelFunction · 0.85

Calls 5

validateBackpressureFunction · 0.85
validateAbortSignalFunction · 0.85
clampHWMFunction · 0.85
onShareCancelFunction · 0.85
fromFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…