44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
Object.defineProperty(exports, "createAsyncLocalStorage", {
|
||
|
enumerable: true,
|
||
|
get: function() {
|
||
|
return createAsyncLocalStorage;
|
||
|
}
|
||
|
});
|
||
|
const sharedAsyncLocalStorageNotAvailableError = new Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");
|
||
|
class FakeAsyncLocalStorage {
|
||
|
disable() {
|
||
|
throw sharedAsyncLocalStorageNotAvailableError;
|
||
|
}
|
||
|
getStore() {
|
||
|
// This fake implementation of AsyncLocalStorage always returns `undefined`.
|
||
|
return undefined;
|
||
|
}
|
||
|
run() {
|
||
|
throw sharedAsyncLocalStorageNotAvailableError;
|
||
|
}
|
||
|
exit() {
|
||
|
throw sharedAsyncLocalStorageNotAvailableError;
|
||
|
}
|
||
|
enterWith() {
|
||
|
throw sharedAsyncLocalStorageNotAvailableError;
|
||
|
}
|
||
|
}
|
||
|
const maybeGlobalAsyncLocalStorage = globalThis.AsyncLocalStorage;
|
||
|
function createAsyncLocalStorage() {
|
||
|
if (maybeGlobalAsyncLocalStorage) {
|
||
|
return new maybeGlobalAsyncLocalStorage();
|
||
|
}
|
||
|
return new FakeAsyncLocalStorage();
|
||
|
}
|
||
|
|
||
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
||
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|
||
|
Object.assign(exports.default, exports);
|
||
|
module.exports = exports.default;
|
||
|
}
|
||
|
|
||
|
//# sourceMappingURL=async-local-storage.js.map
|