MCPcopy Index your code
hub / github.com/cloudflare/capnweb / fromArray

Method fromArray

src/core.ts:719–746  ·  view source on GitHub ↗
(array: RpcPayload[])

Source from the content-addressed store, hash-verified

717 // stubs is transferred from the inputs to the outputs, hence if the output is disposed, the
718 // inputs should not be. (In case of exception, nothing is disposed, though.)
719 public static fromArray(array: RpcPayload[]): RpcPayload {
720 let hooks: StubHook[] = [];
721 let promises: LocatedPromise[] = [];
722
723 let resultArray: unknown[] = [];
724
725 for (let payload of array) {
726 payload.ensureDeepCopied();
727 for (let hook of payload.hooks!) {
728 hooks.push(hook);
729 }
730 for (let promise of payload.promises!) {
731 if (promise.parent === payload) {
732 // This promise is the root of the source payload. We need to reparent it to its proper
733 // location in the result array.
734 promise = {
735 parent: resultArray,
736 property: resultArray.length,
737 promise: promise.promise
738 };
739 }
740 promises.push(promise);
741 }
742 resultArray.push(payload.value);
743 }
744
745 return new RpcPayload(resultArray, "owned", hooks, promises);
746 }
747
748 // Create a payload from a value parsed off the wire using Evaluator.evaluate().
749 //

Callers 1

map.tsFile · 0.80

Calls 1

ensureDeepCopiedMethod · 0.80

Tested by

no test coverage detected