diff options
Diffstat (limited to 'core/core.js')
-rw-r--r-- | core/core.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/core.js b/core/core.js index 23cc325ab..b3c0ddc13 100644 --- a/core/core.js +++ b/core/core.js @@ -37,6 +37,7 @@ SharedQueue Binary Layout let asyncHandlers; let initialized = false; + let opsCache = {}; function maybeInit() { if (!initialized) { @@ -61,7 +62,8 @@ SharedQueue Binary Layout // op id 0 is a special value to retrieve the map of registered ops. const opsMapBytes = send(0, new Uint8Array([])); const opsMapJson = String.fromCharCode.apply(null, opsMapBytes); - return JSON.parse(opsMapJson); + opsCache = JSON.parse(opsMapJson); + return { ...opsCache }; } function assert(cond) { @@ -181,9 +183,14 @@ SharedQueue Binary Layout } } + function dispatch(opName, control, ...zeroCopy) { + return send(opsCache[opName], control, ...zeroCopy); + } + Object.assign(window.Deno.core, { setAsyncHandler, dispatch: send, + dispatchByName: dispatch, ops, // sharedQueue is private but exposed for testing. sharedQueue: { |