MCPcopy Index your code
hub / github.com/andywer/threads.js / prepareArguments

Function prepareArguments

src/master/invocation-proxy.ts:91–116  ·  view source on GitHub ↗
(rawArgs: any[])

Source from the content-addressed store, hash-verified

89}
90
91function prepareArguments(rawArgs: any[]): { args: any[], transferables: Transferable[] } {
92 if (rawArgs.length === 0) {
93 // Exit early if possible
94 return {
95 args: [],
96 transferables: []
97 }
98 }
99
100 const args: any[] = []
101 const transferables: Transferable[] = []
102
103 for (const arg of rawArgs) {
104 if (isTransferDescriptor(arg)) {
105 args.push(serialize(arg.send))
106 transferables.push(...arg.transferables)
107 } else {
108 args.push(serialize(arg))
109 }
110 }
111
112 return {
113 args,
114 transferables: transferables.length === 0 ? transferables : dedupe(transferables)
115 }
116}
117
118export function createProxyFunction<Args extends any[], ReturnType>(worker: WorkerType, method?: string) {
119 return ((...rawArgs: Args) => {

Callers 1

createProxyFunctionFunction · 0.85

Calls 3

isTransferDescriptorFunction · 0.90
serializeFunction · 0.90
dedupeFunction · 0.85

Tested by

no test coverage detected