MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / mergePromise

Function mergePromise

src/integrations/terminal/mergePromise.ts:6–21  ·  view source on GitHub ↗
(process: RooTerminalProcess, promise: Promise<void>)

Source from the content-addressed store, hash-verified

4// TerminalProcess and a Promise:
5// https://github.com/sindresorhus/execa/blob/main/lib/methods/promise.js
6export function mergePromise(process: RooTerminalProcess, promise: Promise<void>): RooTerminalProcessResultPromise {
7 const nativePromisePrototype = (async () => {})().constructor.prototype
8
9 const descriptors = ["then", "catch", "finally"].map(
10 (property) => [property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)] as const,
11 )
12
13 for (const [property, descriptor] of descriptors) {
14 if (descriptor) {
15 const value = descriptor.value.bind(promise)
16 Reflect.defineProperty(process, property, { ...descriptor, value })
17 }
18 }
19
20 return process as RooTerminalProcessResultPromise
21}

Callers 3

runCommandMethod · 0.90
runCommandMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected