MCPcopy Create free account
hub / github.com/vercel/vercel / opAppend

Function opAppend

packages/cli/src/util/dev/transforms.ts:376–397  ·  view source on GitHub ↗
(
  data: TransformData,
  matchedKeys: string[],
  keySelector: KeyRule,
  args: string | string[] | undefined,
  isHeader: boolean
)

Source from the content-addressed store, hash-verified

374}
375
376function opAppend(
377 data: TransformData,
378 matchedKeys: string[],
379 keySelector: KeyRule,
380 args: string | string[] | undefined,
381 isHeader: boolean
382) {
383 if (isEmptyArgs(args)) {
384 return;
385 }
386 const toAppend = typeof args === 'string' ? [args] : (args ?? []);
387
388 for (const key of matchedKeys) {
389 const next = [...toValueList(data[key], isHeader), ...toAppend];
390 setTransformValue(data, key, fromValueList(next));
391 }
392
393 // create new key if nothing matched as key selector is a simple string
394 if (matchedKeys.length === 0 && typeof keySelector === 'string') {
395 setTransformValue(data, keySelector, fromValueList(toAppend));
396 }
397}
398
399function opDelete(
400 data: TransformData,

Callers 1

applyTransformFunction · 0.85

Calls 4

isEmptyArgsFunction · 0.85
toValueListFunction · 0.85
setTransformValueFunction · 0.85
fromValueListFunction · 0.85

Tested by

no test coverage detected