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

Function parsePullArgs

lib/internal/streams/iter/utils.js:246–271  ·  view source on GitHub ↗

* Parse variadic arguments for pull/pullSync. * Returns { transforms, options } * @param {Array} args * @returns {{ transforms: Array, options: object|undefined }}

(args)

Source from the content-addressed store, hash-verified

244 * @returns {{ transforms: Array, options: object|undefined }}
245 */
246function parsePullArgs(args) {
247 if (args.length === 0) {
248 return { __proto__: null, transforms: [], options: undefined };
249 }
250
251 let transforms;
252 let options;
253 const last = args[args.length - 1];
254 if (isPullOptions(last)) {
255 transforms = ArrayPrototypeSlice(args, 0, -1);
256 options = last;
257 } else {
258 transforms = args;
259 options = undefined;
260 }
261
262 for (let i = 0; i < transforms.length; i++) {
263 if (!isTransform(transforms[i])) {
264 throw new ERR_INVALID_ARG_TYPE(
265 `transforms[${i}]`, ['Function', 'Object with transform()'],
266 transforms[i]);
267 }
268 }
269
270 return { __proto__: null, transforms, options };
271}
272
273/**
274 * Validate backpressure option value.

Callers 4

pullMethod · 0.85
pushMethod · 0.85
pullFunction · 0.85
parseArgsFunction · 0.85

Calls 2

isPullOptionsFunction · 0.85
isTransformFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…