| 124 | } |
| 125 | |
| 126 | function wrapAndBindImpl< |
| 127 | Args extends unknown[], |
| 128 | Impl extends (this: Instance, ...args: Args) => Promise<unknown>, |
| 129 | >(instance: Instance, impl: Impl) { |
| 130 | function method(...args: Args) { |
| 131 | setLevelRef(instance, ApiLevel.Call) |
| 132 | |
| 133 | return wrapAsync(() => |
| 134 | impl.apply(instance, args).then(async ret => { |
| 135 | await wait(instance.config) |
| 136 | return ret |
| 137 | }), |
| 138 | ) |
| 139 | } |
| 140 | Object.defineProperty(method, 'name', {get: () => impl.name}) |
| 141 | |
| 142 | return method |
| 143 | } |
| 144 | |
| 145 | export function createInstance( |
| 146 | config: Config, |