diff options
author | 2023-08-02 16:27:36 -0700 | |
---|---|---|
committer | 2023-08-02 16:27:36 -0700 | |
commit | c2a77cf7ec9de9eadf938046bdf78e58561c8a6d (patch) | |
tree | 0f90f1b323061455875333c9f40592b303585973 /src/js/out/modules/node/async_hooks.js | |
parent | 7656b4b17e91f15b58eeab8f45b78c416ec6a045 (diff) | |
download | bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.gz bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.zst bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.zip |
Rewrite built-in modules to use CommonJS over ESM (#3814)
* stfdsafsd
sadffdsa
stuff
finish commonjs stuff
asdf
not done but work
not done but work
not done yet but this is how far i am
remove files
lol
update built files
uncomment everything in events lol
export default
stuff
* afdsafsd
* its not perfect but almost done
* okay
* cool
* remove temp file
* finish rebase
* revert settings.json
* a
* ch-ch-ch-ch-changes
* okay
* remove this check in release for now
* sxdcfghnjm,
* lkjhgf
* fmt
* filename can be null
* Update NodeModuleModule.h
* weee
* fmt
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/js/out/modules/node/async_hooks.js')
-rw-r--r-- | src/js/out/modules/node/async_hooks.js | 229 |
1 files changed, 0 insertions, 229 deletions
diff --git a/src/js/out/modules/node/async_hooks.js b/src/js/out/modules/node/async_hooks.js deleted file mode 100644 index d2659dbcf..000000000 --- a/src/js/out/modules/node/async_hooks.js +++ /dev/null @@ -1,229 +0,0 @@ -var createWarning = function(message) { - let warned = !1; - var wrapped = function() { - if (warned) - return; - if (new Error().stack.includes("zx/build/core.js")) - return; - warned = !0, console.warn("[bun] Warning:", message); - }; - return wrapped; -}, createHook = function(callbacks) { - return { - enable: createHookNotImpl, - disable: createHookNotImpl - }; -}, executionAsyncId = function() { - return executionAsyncIdNotImpl(), 0; -}, triggerAsyncId = function() { - return 0; -}, executionAsyncResource = function() { - return executionAsyncResourceWarning(), process.stdin; -}, { get, set, cleanupLater } = globalThis[Symbol.for("Bun.lazy")]("async_hooks"); - -class AsyncLocalStorage { - #disableCalled = !1; - constructor() { - } - static bind(fn, ...args) { - return this.snapshot().bind(null, fn, ...args); - } - static snapshot() { - var context = get(); - return (fn, ...args) => { - var prev = get(); - set(context); - try { - return fn(...args); - } catch (error) { - throw error; - } finally { - set(prev); - } - }; - } - enterWith(store) { - cleanupLater(); - var context = get(); - if (!context) { - set([this, store]); - return; - } - var { length } = context; - for (var i = 0;i < length; i += 2) - if (context[i] === this) { - const clone = context.slice(); - clone[i + 1] = store, set(clone); - return; - } - set(context.concat(this, store)); - } - exit(cb, ...args) { - return this.run(void 0, cb, ...args); - } - run(store, callback, ...args) { - var context = get(), hasPrevious = !1, previous, i = 0, contextWasInit = !context; - if (contextWasInit) - set(context = [this, store]); - else { - if (context = context.slice(), i = context.indexOf(this), i > -1) - hasPrevious = !0, previous = context[i + 1], context[i + 1] = store; - else - context.push(this, store); - set(context); - } - try { - return callback(...args); - } catch (e) { - throw e; - } finally { - if (!this.#disableCalled) { - var context2 = get(); - if (context2 === context && contextWasInit) - set(void 0); - else if (context2 = context2.slice(), hasPrevious) - context2[i + 1] = previous, set(context2); - else - context2.splice(i, 2), set(context2.length ? context2 : void 0); - } - } - } - disable() { - if (!this.#disableCalled) { - var context = get(); - if (context) { - var { length } = context; - for (var i = 0;i < length; i += 2) - if (context[i] === this) { - context.splice(i, 2), set(context.length ? context : void 0); - break; - } - } - this.#disableCalled = !0; - } - } - getStore() { - var context = get(); - if (!context) - return; - var { length } = context; - for (var i = 0;i < length; i += 2) - if (context[i] === this) - return context[i + 1]; - } -} - -class AsyncResource { - type; - #snapshot; - constructor(type, options) { - if (typeof type !== "string") - throw new TypeError('The "type" argument must be of type string. Received type ' + typeof type); - this.type = type, this.#snapshot = get(); - } - emitBefore() { - return !0; - } - emitAfter() { - return !0; - } - asyncId() { - return 0; - } - triggerAsyncId() { - return 0; - } - emitDestroy() { - } - runInAsyncScope(fn, thisArg, ...args) { - var prev = get(); - set(this.#snapshot); - try { - return fn.apply(thisArg, args); - } catch (error) { - throw error; - } finally { - set(prev); - } - } -} -var createHookNotImpl = createWarning("async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called."), executionAsyncIdNotImpl = createWarning("async_hooks.executionAsyncId/triggerAsyncId are not implemented in Bun. It will return 0 every time."), executionAsyncResourceWarning = createWarning("async_hooks.executionAsyncResource is not implemented in Bun. It returns a reference to process.stdin every time."), asyncWrapProviders = { - NONE: 0, - DIRHANDLE: 1, - DNSCHANNEL: 2, - ELDHISTOGRAM: 3, - FILEHANDLE: 4, - FILEHANDLECLOSEREQ: 5, - FIXEDSIZEBLOBCOPY: 6, - FSEVENTWRAP: 7, - FSREQCALLBACK: 8, - FSREQPROMISE: 9, - GETADDRINFOREQWRAP: 10, - GETNAMEINFOREQWRAP: 11, - HEAPSNAPSHOT: 12, - HTTP2SESSION: 13, - HTTP2STREAM: 14, - HTTP2PING: 15, - HTTP2SETTINGS: 16, - HTTPINCOMINGMESSAGE: 17, - HTTPCLIENTREQUEST: 18, - JSSTREAM: 19, - JSUDPWRAP: 20, - MESSAGEPORT: 21, - PIPECONNECTWRAP: 22, - PIPESERVERWRAP: 23, - PIPEWRAP: 24, - PROCESSWRAP: 25, - PROMISE: 26, - QUERYWRAP: 27, - SHUTDOWNWRAP: 28, - SIGNALWRAP: 29, - STATWATCHER: 30, - STREAMPIPE: 31, - TCPCONNECTWRAP: 32, - TCPSERVERWRAP: 33, - TCPWRAP: 34, - TTYWRAP: 35, - UDPSENDWRAP: 36, - UDPWRAP: 37, - SIGINTWATCHDOG: 38, - WORKER: 39, - WORKERHEAPSNAPSHOT: 40, - WRITEWRAP: 41, - ZLIB: 42, - CHECKPRIMEREQUEST: 43, - PBKDF2REQUEST: 44, - KEYPAIRGENREQUEST: 45, - KEYGENREQUEST: 46, - KEYEXPORTREQUEST: 47, - CIPHERREQUEST: 48, - DERIVEBITSREQUEST: 49, - HASHREQUEST: 50, - RANDOMBYTESREQUEST: 51, - RANDOMPRIMEREQUEST: 52, - SCRYPTREQUEST: 53, - SIGNREQUEST: 54, - TLSWRAP: 55, - VERIFYREQUEST: 56, - INSPECTORJSBINDING: 57 -}; -var async_hooks_default = { - AsyncLocalStorage, - createHook, - executionAsyncId, - triggerAsyncId, - executionAsyncResource, - asyncWrapProviders, - AsyncResource, - [Symbol.for("CommonJS")]: 0 -}; -export { - triggerAsyncId, - executionAsyncResource, - executionAsyncId, - async_hooks_default as default, - createHook, - asyncWrapProviders, - AsyncResource, - AsyncLocalStorage -}; |