diff options
author | James M Snell <jasnell@gmail.com> | 2020-05-23 04:11:14 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-05 22:21:47 +0300 |
commit | 74ca960aac4600953caacd5f250b11a90bd70ee7 (patch) | |
tree | 241afade93b93c034e23339896e7386f32c3b3e9 /lib/internal/bootstrap | |
parent | 3e2a3007107b7a100794f4e4adbde19263fc7464 (diff) |
lib: initial experimental AbortController implementation
AbortController impl based very closely on:
https://github.com/mysticatea/abort-controller
Marked experimental.
Not currently used by any of the existing promise apis.
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/33527
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/bootstrap')
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index f60814d2dc9..9a0b2c361d3 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -3,6 +3,7 @@ const { Map, ObjectDefineProperty, + ObjectDefineProperties, SafeWeakMap, } = primordials; @@ -53,6 +54,7 @@ function prepareMainThreadExecution(expandArgv1 = false) { // (including preload modules). initializeClusterIPC(); + initializeAbortController(); initializeDeprecations(); initializeWASI(); initializeCJSLoader(); @@ -304,6 +306,30 @@ function initializeDeprecations() { }); } +function initializeAbortController() { + const abortController = getOptionValue('--experimental-abortcontroller'); + if (abortController) { + const { + AbortController, + AbortSignal + } = require('internal/abort_controller'); + ObjectDefineProperties(global, { + AbortController: { + writable: true, + enumerable: false, + configurable: true, + value: AbortController + }, + AbortSignal: { + writable: true, + enumerable: false, + configurable: true, + value: AbortSignal + } + }); + } +} + function setupChildProcessIpcChannel() { if (process.env.NODE_CHANNEL_FD) { const assert = require('internal/assert'); @@ -438,6 +464,7 @@ module.exports = { setupWarningHandler, setupDebugEnv, prepareMainThreadExecution, + initializeAbortController, initializeDeprecations, initializeESMLoader, initializeFrozenIntrinsics, |