@jfrz38/adaptive-admission-node 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ import { componentErrorPayload, createComponentController, defaultComponentConfig, } from './component-runtime.js';
2
+ import { ConfigurationError } from './errors.js';
3
+ const MAX_U64 = (1n << 64n) - 1n;
4
+ function toU64(field, value) {
5
+ let converted;
6
+ if (typeof value === 'number') {
7
+ if (!Number.isSafeInteger(value)) {
8
+ throw new RangeError(`${field} must be a safe integer or bigint`);
9
+ }
10
+ converted = BigInt(value);
11
+ }
12
+ else {
13
+ converted = value;
14
+ }
15
+ if (converted < 0n || converted > MAX_U64) {
16
+ throw new RangeError(`${field} must be between 0 and 2^64 - 1`);
17
+ }
18
+ return converted;
19
+ }
20
+ export function resolveConfiguration(options = {}) {
21
+ const defaults = defaultComponentConfig();
22
+ return {
23
+ initialThreshold: options.initialThreshold ?? defaults.initialThreshold,
24
+ maxConcurrentRequests: options.maxConcurrentRequests === undefined
25
+ ? defaults.maxConcurrentRequests
26
+ : toU64('maxConcurrentRequests', options.maxConcurrentRequests),
27
+ maxQueuedRequests: options.maxQueuedRequests === undefined
28
+ ? defaults.maxQueuedRequests
29
+ : toU64('maxQueuedRequests', options.maxQueuedRequests),
30
+ queueTimeoutMs: options.queueTimeoutMs === undefined
31
+ ? defaults.queueTimeoutMs
32
+ : toU64('queueTimeoutMs', options.queueTimeoutMs),
33
+ queueTimeoutRatio: options.queueTimeoutRatio ?? defaults.queueTimeoutRatio,
34
+ statistics: {
35
+ minWindowMs: options.statistics?.minWindowMs === undefined
36
+ ? defaults.statistics.minWindowMs
37
+ : toU64('statistics.minWindowMs', options.statistics.minWindowMs),
38
+ maxWindowMs: options.statistics?.maxWindowMs === undefined
39
+ ? defaults.statistics.maxWindowMs
40
+ : toU64('statistics.maxWindowMs', options.statistics.maxWindowMs),
41
+ minSamples: options.statistics?.minSamples === undefined
42
+ ? defaults.statistics.minSamples
43
+ : toU64('statistics.minSamples', options.statistics.minSamples),
44
+ minPercentileSamples: options.statistics?.minPercentileSamples === undefined
45
+ ? defaults.statistics.minPercentileSamples
46
+ : toU64('statistics.minPercentileSamples', options.statistics.minPercentileSamples),
47
+ maxSamples: options.statistics?.maxSamples === undefined
48
+ ? defaults.statistics.maxSamples
49
+ : toU64('statistics.maxSamples', options.statistics.maxSamples),
50
+ latencyPercentile: options.statistics?.latencyPercentile ?? defaults.statistics.latencyPercentile,
51
+ },
52
+ pid: {
53
+ proportionalGain: options.pid?.proportionalGain ?? defaults.pid.proportionalGain,
54
+ integralGain: options.pid?.integralGain ?? defaults.pid.integralGain,
55
+ derivativeGain: options.pid?.derivativeGain ?? defaults.pid.derivativeGain,
56
+ intervalMs: options.pid?.intervalMs === undefined
57
+ ? defaults.pid.intervalMs
58
+ : toU64('pid.intervalMs', options.pid.intervalMs),
59
+ maxDeltaPercentage: options.pid?.maxDeltaPercentage ?? defaults.pid.maxDeltaPercentage,
60
+ integralDecay: options.pid?.integralDecay ?? defaults.pid.integralDecay,
61
+ },
62
+ };
63
+ }
64
+ export function createValidatedComponentController(options = {}) {
65
+ try {
66
+ return createComponentController(resolveConfiguration(options));
67
+ }
68
+ catch (error) {
69
+ const payload = componentErrorPayload(error);
70
+ if (isErrorPayload(payload)) {
71
+ throw new ConfigurationError(payload);
72
+ }
73
+ throw error;
74
+ }
75
+ }
76
+ function isErrorPayload(payload) {
77
+ return typeof payload === 'object'
78
+ && payload !== null
79
+ && 'tag' in payload
80
+ && typeof payload.tag === 'string';
81
+ }
@@ -0,0 +1,46 @@
1
+ import { Priority } from './priority.js';
2
+ import type { ControllerDiagnosticListener, ControllerOptions, RunOptions, StatisticsSnapshot } from './types.js';
3
+ export interface MonotonicClock {
4
+ nowMilliseconds(): bigint;
5
+ }
6
+ export interface DeadlineScheduler {
7
+ schedule(callback: () => void, delayMilliseconds: number): unknown;
8
+ cancel(handle: unknown): void;
9
+ }
10
+ export interface ControllerDependencies {
11
+ clock: MonotonicClock;
12
+ scheduler: DeadlineScheduler;
13
+ defer(callback: () => void): void;
14
+ }
15
+ export declare class AdaptiveAdmissionController {
16
+ private readonly dependencies;
17
+ private readonly component;
18
+ private readonly pending;
19
+ private timer;
20
+ private timerGeneration;
21
+ private shutdownRequested;
22
+ private readonly diagnosticListeners;
23
+ private latestPublishedStatisticsId;
24
+ private latestControllerDiagnostics;
25
+ constructor(options?: ControllerOptions, dependencies?: ControllerDependencies);
26
+ run<T>(task: () => T | Promise<T>, priority?: Priority, options?: RunOptions): Promise<T>;
27
+ shutdown(): void;
28
+ latestStatistics(): StatisticsSnapshot | undefined;
29
+ priorityPercentile(percentile: number): number | undefined;
30
+ onDiagnostic(listener: ControllerDiagnosticListener): () => void;
31
+ private processActions;
32
+ private publishControllerDiagnostics;
33
+ private publishDiagnostic;
34
+ private start;
35
+ private completeSuccess;
36
+ private completeFailure;
37
+ private reject;
38
+ private settleRejected;
39
+ private observeAbort;
40
+ private cancelQueued;
41
+ private removeAbortListener;
42
+ private rescheduleDeadline;
43
+ private clearTimer;
44
+ private now;
45
+ private translateProtocolError;
46
+ }
@@ -0,0 +1,311 @@
1
+ import { componentErrorPayload, } from './component-runtime.js';
2
+ import { createValidatedComponentController } from './configuration.js';
3
+ import { CancelledRequestError, ControllerProtocolError, ControllerShutdownError, EvictedRequestError, QueueFullError, ThresholdRejectedError, } from './errors.js';
4
+ import { Priority } from './priority.js';
5
+ const systemDependencies = {
6
+ clock: {
7
+ nowMilliseconds: () => process.hrtime.bigint() / 1000000n,
8
+ },
9
+ scheduler: {
10
+ schedule: (callback, delayMilliseconds) => setTimeout(callback, delayMilliseconds),
11
+ cancel: (handle) => clearTimeout(handle),
12
+ },
13
+ defer: queueMicrotask,
14
+ };
15
+ const MAX_TIMER_DELAY_MS = 2147483647n;
16
+ export class AdaptiveAdmissionController {
17
+ dependencies;
18
+ component;
19
+ pending = new Map();
20
+ timer;
21
+ timerGeneration = 0;
22
+ shutdownRequested = false;
23
+ diagnosticListeners = new Set();
24
+ latestPublishedStatisticsId;
25
+ latestControllerDiagnostics;
26
+ constructor(options = {}, dependencies = systemDependencies) {
27
+ this.dependencies = dependencies;
28
+ this.component = createValidatedComponentController(options);
29
+ }
30
+ run(task, priority = Priority.default(), options = {}) {
31
+ if (this.shutdownRequested) {
32
+ return Promise.reject(new ControllerShutdownError());
33
+ }
34
+ if (options.signal?.aborted) {
35
+ return Promise.reject(new CancelledRequestError(undefined, 'requested'));
36
+ }
37
+ let resolve;
38
+ let reject;
39
+ const promise = new Promise((resolvePromise, rejectPromise) => {
40
+ resolve = resolvePromise;
41
+ reject = rejectPromise;
42
+ });
43
+ try {
44
+ const submission = this.component.submit(priority.value, this.now());
45
+ this.pending.set(submission.requestId, { task, resolve, reject, state: 'queued' });
46
+ this.processActions(submission.actions);
47
+ this.observeAbort(submission.requestId, options.signal);
48
+ this.rescheduleDeadline();
49
+ }
50
+ catch (error) {
51
+ reject(this.translateProtocolError(error));
52
+ }
53
+ return promise;
54
+ }
55
+ shutdown() {
56
+ if (this.shutdownRequested) {
57
+ return;
58
+ }
59
+ this.shutdownRequested = true;
60
+ try {
61
+ this.processActions(this.component.shutdown(this.now()));
62
+ this.rescheduleDeadline();
63
+ }
64
+ catch (error) {
65
+ this.clearTimer();
66
+ throw this.translateProtocolError(error);
67
+ }
68
+ }
69
+ latestStatistics() {
70
+ return this.component.latestStatistics();
71
+ }
72
+ priorityPercentile(percentile) {
73
+ if (!Number.isInteger(percentile) || percentile < 0 || percentile > 100) {
74
+ throw new RangeError('percentile must be an integer between 0 and 100');
75
+ }
76
+ return this.component.priorityPercentile(percentile);
77
+ }
78
+ onDiagnostic(listener) {
79
+ this.diagnosticListeners.add(listener);
80
+ return () => this.diagnosticListeners.delete(listener);
81
+ }
82
+ processActions(actions) {
83
+ const diagnostics = [];
84
+ for (const action of actions) {
85
+ switch (action.tag) {
86
+ case 'start':
87
+ this.start(action.val);
88
+ break;
89
+ case 'reject':
90
+ this.reject(action.val.requestId, action.val.reason);
91
+ break;
92
+ case 'evict':
93
+ this.settleRejected(action.val.requestId, new EvictedRequestError(action.val.requestId));
94
+ break;
95
+ case 'cancel':
96
+ this.settleRejected(action.val.requestId, action.val.reason === 'shutdown'
97
+ ? new ControllerShutdownError(action.val.requestId)
98
+ : new CancelledRequestError(action.val.requestId, action.val.reason));
99
+ break;
100
+ case 'threshold-changed':
101
+ diagnostics.push({
102
+ type: 'threshold-changed',
103
+ previous: action.val.previous,
104
+ current: action.val.current,
105
+ });
106
+ break;
107
+ case 'concurrency-changed':
108
+ diagnostics.push({
109
+ type: 'concurrency-changed',
110
+ previous: action.val.previous,
111
+ current: action.val.current,
112
+ });
113
+ break;
114
+ }
115
+ }
116
+ const statistics = this.component.latestStatistics();
117
+ if (statistics !== undefined && statistics.id !== this.latestPublishedStatisticsId) {
118
+ this.latestPublishedStatisticsId = statistics.id;
119
+ diagnostics.push({ type: 'statistics-published', snapshot: statistics });
120
+ }
121
+ for (const diagnostic of diagnostics) {
122
+ this.publishDiagnostic(diagnostic);
123
+ }
124
+ this.publishControllerDiagnostics();
125
+ }
126
+ publishControllerDiagnostics() {
127
+ const componentDiagnostics = this.component.latestDiagnostics();
128
+ const diagnostics = {
129
+ threshold: componentDiagnostics.threshold,
130
+ concurrencyLimit: componentDiagnostics.concurrencyLimit,
131
+ queueTimeoutMs: componentDiagnostics.queueTimeoutMs,
132
+ targetLatencyMs: componentDiagnostics.targetLatencyMs,
133
+ aggregatedLatencyMs: componentDiagnostics.aggregatedLatencyMs,
134
+ };
135
+ if (sameDiagnostics(this.latestControllerDiagnostics, diagnostics)) {
136
+ return;
137
+ }
138
+ this.latestControllerDiagnostics = diagnostics;
139
+ this.publishDiagnostic({ type: 'controller-diagnostics', diagnostics });
140
+ }
141
+ publishDiagnostic(diagnostic) {
142
+ for (const listener of this.diagnosticListeners) {
143
+ try {
144
+ listener(diagnostic);
145
+ }
146
+ catch {
147
+ // Diagnostic consumers must not change admission or task outcomes.
148
+ }
149
+ }
150
+ }
151
+ start(requestId) {
152
+ const pending = this.pending.get(requestId);
153
+ if (!pending || pending.state !== 'queued') {
154
+ throw new Error(`component started unknown or non-queued request ${requestId}`);
155
+ }
156
+ pending.state = 'started';
157
+ this.removeAbortListener(pending);
158
+ this.dependencies.defer(() => {
159
+ Promise.resolve()
160
+ .then(pending.task)
161
+ .then((value) => this.completeSuccess(requestId, pending, value), (error) => this.completeFailure(requestId, pending, error));
162
+ });
163
+ }
164
+ completeSuccess(requestId, pending, value) {
165
+ this.pending.delete(requestId);
166
+ try {
167
+ this.processActions(this.component.complete(requestId, 'success', this.now()));
168
+ pending.resolve(value);
169
+ }
170
+ catch (error) {
171
+ pending.reject(this.translateProtocolError(error));
172
+ }
173
+ finally {
174
+ this.rescheduleDeadline();
175
+ }
176
+ }
177
+ completeFailure(requestId, pending, taskError) {
178
+ this.pending.delete(requestId);
179
+ try {
180
+ this.processActions(this.component.complete(requestId, 'failure', this.now()));
181
+ }
182
+ catch {
183
+ // The task's original failure remains the public result. Protocol failures are not allowed to
184
+ // replace application errors after the task has already run.
185
+ }
186
+ finally {
187
+ pending.reject(taskError);
188
+ this.rescheduleDeadline();
189
+ }
190
+ }
191
+ reject(requestId, reason) {
192
+ switch (reason.tag) {
193
+ case 'threshold':
194
+ this.settleRejected(requestId, new ThresholdRejectedError(requestId, reason.val.priority, reason.val.threshold));
195
+ break;
196
+ case 'queue-full':
197
+ this.settleRejected(requestId, new QueueFullError(requestId));
198
+ break;
199
+ case 'shutdown':
200
+ this.settleRejected(requestId, new ControllerShutdownError(requestId));
201
+ break;
202
+ }
203
+ }
204
+ settleRejected(requestId, error) {
205
+ const pending = this.pending.get(requestId);
206
+ if (!pending) {
207
+ throw new Error(`component settled unknown request ${requestId}`);
208
+ }
209
+ this.pending.delete(requestId);
210
+ this.removeAbortListener(pending);
211
+ pending.reject(error);
212
+ }
213
+ observeAbort(requestId, signal) {
214
+ const pending = this.pending.get(requestId);
215
+ if (!signal || !pending || pending.state !== 'queued') {
216
+ return;
217
+ }
218
+ const listener = () => this.cancelQueued(requestId);
219
+ pending.abort = { signal, listener };
220
+ signal.addEventListener('abort', listener, { once: true });
221
+ if (signal.aborted) {
222
+ listener();
223
+ }
224
+ }
225
+ cancelQueued(requestId) {
226
+ const pending = this.pending.get(requestId);
227
+ if (!pending || pending.state !== 'queued') {
228
+ return;
229
+ }
230
+ try {
231
+ this.processActions(this.component.cancel(requestId, this.now()));
232
+ }
233
+ catch (error) {
234
+ this.pending.delete(requestId);
235
+ this.removeAbortListener(pending);
236
+ pending.reject(this.translateProtocolError(error));
237
+ }
238
+ finally {
239
+ this.rescheduleDeadline();
240
+ }
241
+ }
242
+ removeAbortListener(pending) {
243
+ if (pending.abort) {
244
+ pending.abort.signal.removeEventListener('abort', pending.abort.listener);
245
+ pending.abort = undefined;
246
+ }
247
+ }
248
+ rescheduleDeadline() {
249
+ this.clearTimer();
250
+ const deadline = this.component.nextDeadline();
251
+ if (deadline === undefined) {
252
+ return;
253
+ }
254
+ const generation = ++this.timerGeneration;
255
+ const remaining = deadline > this.now() ? deadline - this.now() : 0n;
256
+ const boundedDelay = remaining > MAX_TIMER_DELAY_MS ? MAX_TIMER_DELAY_MS : remaining;
257
+ this.timer = this.dependencies.scheduler.schedule(() => {
258
+ if (generation !== this.timerGeneration) {
259
+ return;
260
+ }
261
+ this.timer = undefined;
262
+ try {
263
+ this.processActions(this.component.advanceTime(this.now()));
264
+ }
265
+ finally {
266
+ this.rescheduleDeadline();
267
+ }
268
+ }, Number(boundedDelay));
269
+ }
270
+ clearTimer() {
271
+ this.timerGeneration += 1;
272
+ if (this.timer !== undefined) {
273
+ this.dependencies.scheduler.cancel(this.timer);
274
+ this.timer = undefined;
275
+ }
276
+ }
277
+ now() {
278
+ return this.dependencies.clock.nowMilliseconds();
279
+ }
280
+ translateProtocolError(error) {
281
+ const payload = componentErrorPayload(error);
282
+ if (isSubmitError(payload) && payload.tag === 'controller') {
283
+ return new ControllerProtocolError(payload.val);
284
+ }
285
+ if (isControllerError(payload)) {
286
+ return new ControllerProtocolError(payload);
287
+ }
288
+ return error;
289
+ }
290
+ }
291
+ function isControllerError(payload) {
292
+ return typeof payload === 'object'
293
+ && payload !== null
294
+ && 'tag' in payload
295
+ && typeof payload.tag === 'string';
296
+ }
297
+ function isSubmitError(payload) {
298
+ return typeof payload === 'object'
299
+ && payload !== null
300
+ && 'tag' in payload
301
+ && payload.tag === 'controller'
302
+ && 'val' in payload;
303
+ }
304
+ function sameDiagnostics(previous, current) {
305
+ return previous !== undefined
306
+ && previous.threshold === current.threshold
307
+ && previous.concurrencyLimit === current.concurrencyLimit
308
+ && previous.queueTimeoutMs === current.queueTimeoutMs
309
+ && previous.targetLatencyMs === current.targetLatencyMs
310
+ && previous.aggregatedLatencyMs === current.aggregatedLatencyMs;
311
+ }
@@ -0,0 +1,38 @@
1
+ import type { ConfigurationErrorPayload, ControllerErrorPayload } from './types.js';
2
+ export declare class AdaptiveAdmissionError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ export declare class AdmissionRequestError extends AdaptiveAdmissionError {
6
+ }
7
+ export declare class ConfigurationError extends AdaptiveAdmissionError {
8
+ readonly payload: ConfigurationErrorPayload;
9
+ constructor(payload: ConfigurationErrorPayload);
10
+ }
11
+ export declare class ControllerProtocolError extends AdaptiveAdmissionError {
12
+ readonly payload: ControllerErrorPayload;
13
+ constructor(payload: ControllerErrorPayload);
14
+ }
15
+ export declare class RejectedRequestError extends AdmissionRequestError {
16
+ readonly requestId: bigint | undefined;
17
+ constructor(requestId: bigint | undefined, message: string);
18
+ }
19
+ export declare class ThresholdRejectedError extends RejectedRequestError {
20
+ readonly priority: number;
21
+ readonly threshold: number;
22
+ constructor(requestId: bigint, priority: number, threshold: number);
23
+ }
24
+ export declare class QueueFullError extends RejectedRequestError {
25
+ constructor(requestId: bigint);
26
+ }
27
+ export declare class ControllerShutdownError extends RejectedRequestError {
28
+ constructor(requestId?: bigint);
29
+ }
30
+ export declare class EvictedRequestError extends AdmissionRequestError {
31
+ readonly requestId: bigint;
32
+ constructor(requestId: bigint);
33
+ }
34
+ export declare class CancelledRequestError extends AdmissionRequestError {
35
+ readonly requestId: bigint | undefined;
36
+ readonly reason: 'requested' | 'shutdown';
37
+ constructor(requestId: bigint | undefined, reason: 'requested' | 'shutdown');
38
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,68 @@
1
+ export class AdaptiveAdmissionError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = new.target.name;
5
+ }
6
+ }
7
+ export class AdmissionRequestError extends AdaptiveAdmissionError {
8
+ }
9
+ export class ConfigurationError extends AdaptiveAdmissionError {
10
+ payload;
11
+ constructor(payload) {
12
+ super(`Invalid adaptive admission configuration: ${payload.tag}`);
13
+ this.payload = payload;
14
+ }
15
+ }
16
+ export class ControllerProtocolError extends AdaptiveAdmissionError {
17
+ payload;
18
+ constructor(payload) {
19
+ super(`Adaptive admission controller error: ${payload.tag}`);
20
+ this.payload = payload;
21
+ }
22
+ }
23
+ export class RejectedRequestError extends AdmissionRequestError {
24
+ requestId;
25
+ constructor(requestId, message) {
26
+ super(message);
27
+ this.requestId = requestId;
28
+ }
29
+ }
30
+ export class ThresholdRejectedError extends RejectedRequestError {
31
+ priority;
32
+ threshold;
33
+ constructor(requestId, priority, threshold) {
34
+ super(requestId, `Request ${requestId} was rejected because priority ${priority} is outside threshold ${threshold}`);
35
+ this.priority = priority;
36
+ this.threshold = threshold;
37
+ }
38
+ }
39
+ export class QueueFullError extends RejectedRequestError {
40
+ constructor(requestId) {
41
+ super(requestId, `Request ${requestId} was rejected because the admission queue is full`);
42
+ }
43
+ }
44
+ export class ControllerShutdownError extends RejectedRequestError {
45
+ constructor(requestId) {
46
+ super(requestId, requestId === undefined
47
+ ? 'The controller is shut down'
48
+ : `Request ${requestId} was rejected because the controller is shut down`);
49
+ }
50
+ }
51
+ export class EvictedRequestError extends AdmissionRequestError {
52
+ requestId;
53
+ constructor(requestId) {
54
+ super(`Request ${requestId} was evicted after exceeding its queue deadline`);
55
+ this.requestId = requestId;
56
+ }
57
+ }
58
+ export class CancelledRequestError extends AdmissionRequestError {
59
+ requestId;
60
+ reason;
61
+ constructor(requestId, reason) {
62
+ super(requestId === undefined
63
+ ? `Request was cancelled before submission: ${reason}`
64
+ : `Request ${requestId} was cancelled: ${reason}`);
65
+ this.requestId = requestId;
66
+ this.reason = reason;
67
+ }
68
+ }
@@ -0,0 +1,57 @@
1
+ // world root:component/root
2
+ import type * as Jfrz38AdaptiveAdmissionController from './interfaces/jfrz38-adaptive-admission-controller.js'; // jfrz38:adaptive-admission/controller@0.1.0
3
+ export interface ImportObject {
4
+ }
5
+ export interface Root {
6
+ "jfrz38:adaptive-admission/controller@0.1.0": typeof Jfrz38AdaptiveAdmissionController,
7
+ controller: typeof Jfrz38AdaptiveAdmissionController,
8
+ }
9
+
10
+ /**
11
+ * Options accepted by `instantiate`.
12
+ */
13
+ export interface InstantiateOptions {
14
+ /** Runtime overrides for this instance. */
15
+ shim?: {
16
+ /** Platform globals used instead of those on `globalThis`. */
17
+ globals?: {
18
+ /**
19
+ * The WebAssembly implementation used by this instance,
20
+ * including by the default `instantiateCore`. Defaults to
21
+ * `globalThis.WebAssembly`.
22
+ */
23
+ WebAssembly?: typeof WebAssembly;
24
+ };
25
+ };
26
+ }
27
+
28
+
29
+ /**
30
+ * Instantiates this component with the provided imports and
31
+ * returns a map of all the exports of the component.
32
+ *
33
+ * This function is intended to be similar to the
34
+ * `WebAssembly.Instantiate` constructor. The second `imports`
35
+ * argument is the "import object" for wasm, except here it
36
+ * uses component-model-layer types instead of core wasm
37
+ * integers/numbers/etc.
38
+ *
39
+ * The first argument to this function, `getCoreModule`, is
40
+ * used to compile core wasm modules within the component.
41
+ * Components are composed of core wasm modules and this callback
42
+ * will be invoked per core wasm module. The caller of this
43
+ * function is responsible for reading the core wasm module
44
+ * identified by `path` and returning its compiled
45
+ * `WebAssembly.Module` object. This would use the
46
+ * `WebAssembly.Module` constructor on the web, for example.
47
+ *
48
+ * The optional `options` argument configures instantiation; see
49
+ * `InstantiateOptions`.
50
+ */
51
+ export function instantiate(
52
+ getCoreModule: (path: string) => WebAssembly.Module,
53
+ imports: ImportObject,
54
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance,
55
+ options?: InstantiateOptions
56
+ ): Root;
57
+