MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / parsePipeToArgs

Function parsePipeToArgs

src/pull.js:129–153  ·  view source on GitHub ↗

* Parse variadic arguments for pipeTo/pipeToSync. * Returns { transforms, writer, options }

(args)

Source from the content-addressed store, hash-verified

127 * Returns { transforms, writer, options }
128 */
129function parsePipeToArgs(args) {
130 if (args.length === 0) {
131 throw new TypeError('pipeTo requires a writer argument');
132 }
133 var options;
134 var writerIndex = args.length - 1;
135 // Check if last arg is options
136 var last = args[args.length - 1];
137 if ((0, utils_js_1.isPullOptions)(last) && !isWriter(last)) {
138 options = last;
139 writerIndex = args.length - 2;
140 }
141 if (writerIndex < 0) {
142 throw new TypeError('pipeTo requires a writer argument');
143 }
144 var writer = args[writerIndex];
145 if (!isWriter(writer)) {
146 throw new TypeError('pipeTo requires a writer argument with a write method');
147 }
148 return {
149 transforms: args.slice(0, writerIndex),
150 writer: writer,
151 options: options,
152 };
153}
154// =============================================================================
155// Transform Output Flattening
156// =============================================================================

Callers 2

pipeToSyncFunction · 0.70
pipeToFunction · 0.70

Calls 1

isWriterFunction · 0.70

Tested by

no test coverage detected