MCPcopy
hub / github.com/vercel/next.js / omitUnusedArgs

Function omitUnusedArgs

packages/next/src/shared/lib/server-reference-info.ts:60–83  ·  view source on GitHub ↗
(
  args: unknown[],
  info: ServerReferenceInfo
)

Source from the content-addressed store, hash-verified

58 * provided action info.
59 */
60export function omitUnusedArgs(
61 args: unknown[],
62 info: ServerReferenceInfo
63): unknown[] {
64 const filteredArgs = new Array(args.length)
65 let length = 0
66
67 for (let index = 0; index < args.length; index++) {
68 if (
69 (index < 6 && info.usedArgs[index]) ||
70 // This assumes that the server reference info byte has the restArgs bit
71 // set to 1 if there are more than 6 args.
72 (index >= 6 && info.hasRestArgs)
73 ) {
74 filteredArgs[index] = args[index]
75 length = index + 1
76 }
77 }
78
79 // Trim trailing unused args from the array.
80 filteredArgs.length = length
81
82 return filteredArgs
83}

Callers 2

fetchServerActionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected