( args: unknown[], info: ServerReferenceInfo )
| 58 | * provided action info. |
| 59 | */ |
| 60 | export 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 | } |
no outgoing calls
no test coverage detected