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,CAAC,IACd,GAAI,EAAU,WAAY,EAAE,IAChC,SAAS,EAAS,GAoBlB,EAAU,OAAQ,EAAK,CAAC,EAAG,GAAK,CAAC,EAAG,EAAG,IAMlC,GAAI,EAAU,aAAc,CAAC,IAc7B,GAAI,EAAU,OAAQ,CAAC,EAAG,EAAG,IAElC,cAAc,QAAS,EAAS,EAAI,GAG7B,EAKP,SAAS,EAAW,EAAY,GAC/B,WAAW,EAAS,EAAY,EAAM,EACvC,CAEA,SAAS,EAAU,EAAY,GAC9B,WAAW,EAAQ,UAAW,EAAY,EAAM,EACjD,CAEA,SAAS,EAAS,EAAY,GAC7B,EAAU,EAAY,GACtB,EAAW,EAAY,EAAK,KAAI,SAAS,GAAO,OAAO,EAAM,EAAI,EAAM,EAAM,CAAG,IACjF,CACD","file":"/npm/cls-bluebird@2.1.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cls-bluebird@2.1.0/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\n/*\n * cls-bluebird\n * Module entry point\n */\n\n// Modules\nvar isBluebird = require('is-bluebird');\n\n// Require Bluebird library\n// Ignore errors if cannot be required\nvar Bluebird;\ntry {\n\tBluebird = require('bluebird');\n} catch (err) {}\n\n// Imports\nvar shimMethod = require('./shimMethod'),\n\tshimOnCancel = require('./shimOnCancel'),\n\tshimCall = require('./shimCall'),\n\tshimUsing = require('./shimUsing'),\n\tshimCoroutine = require('./shimCoroutine');\n\n// Exports\n\n/**\n * Patch bluebird to run maintain CLS context for a specific namespace.\n * If a Bluebird Promise constructor is provided, it is patched.\n * If not provided, the version returned by `require('bluebird')` is used.\n *\n * @param {Object} ns - CLS namespace object\n * @param {Function} [Promise] - Bluebird Promise constructor to patch (optional)\n * @returns {Function} - Bluebird Promise constructor\n * @throws {TypeError} - If `ns` or `Promise` are not of correct type\n * @throws {Error} - If `Promise` not provided and cannot require `bluebird` module\n */\nmodule.exports = function patchBluebird(ns, Promise) {\n\t// Check namespace is valid\n\tif (!ns || typeof ns !== 'object' || typeof ns.bind !== 'function' || typeof ns.run !== 'function') throw new TypeError('Must provide CLS namespace to patch Bluebird against');\n\n\t// Check Promise implementation is some variation of Bluebird\n\t// If none provided, use default Bluebird\n\tif (!Promise) {\n\t\tPromise = Bluebird;\n\t\tif (!Promise) throw new Error('Could not require Bluebird');\n\t} else if (!isBluebird.ctor(Promise)) {\n\t\tthrow new TypeError('Promise implementation provided must be Bluebird');\n\t}\n\n\t// Patch all methods to carry CLS context\n\tvar v3 = isBluebird.ctor.v3(Promise);\n\n\t/*\n\t * Core\n\t *\n\t * Not patched as always run callback synchronously:\n\t *   new Promise()\n\t *   Promise.try() / Promise.attempt()\n\t *\n\t * Not patched as do not take a callback:\n\t *   Promise.bind() / .bind()\n\t *   Promise.resolve() / Promise.fulfilled() / Promise.cast()\n\t *   Promise.reject() / Promise.rejected()\n\t *\n\t * Not patched as call another patched method synchronously\n\t *   .error() - calls .catch()\n\t *\n\t * Not patched as are wrappers:\n\t *   Promise.method()\n\t *\n\t * NB Due to bug in bluebird v2 https://github.com/petkaantonov/bluebird/issues/1153\n\t * `Promise.join()` calls the callback synchronously if input is only values or\n\t * resolved promises, but async if any promises are pending.\n\t * So handler is sometimes bound to CLS context unnecessarily, but this does no harm\n\t * beyond the very slight performance overhead of an extra `ns.bind()` call.\n\t */\n\n\tshimProto('then', v3 ? [0, 1] : [0, 1, 2]);\n\tshimProto('spread', v3 ? [0] : [0, 1]);\n\tshimProto('finally', [0]);\n\tPromise.prototype.lastly = Promise.prototype.finally;\n\tshimStatic('join', [-1]);\n\n\tif (!v3) {\n\t\t// Only patched in bluebird v2.\n\t\t// In bluebird v3 `.catch()` calls `.then()` immediately which binds callback.\n\t\tshimProto('catch', [-1]);\n\t\tPromise.prototype.caught = Promise.prototype.catch;\n\t}\n\n\t/*\n\t * Synchronous inspection\n\t *\n\t * Not patched as do not take a callback:\n\t *   .isFulfilled()\n\t *   .isRejected()\n\t *   .isPending()\n\t *   .isCancelled()\n\t *   .isResolved()\n\t *   .value()\n\t *   .reason()\n\t *   .reflect()\n\t */\n\n\t/*\n\t * Collections\n\t *\n\t * Not patched as do not take a callback:\n\t *   Promise.all() / .all()\n\t *   Promise.props() / .props()\n\t *   Promise.any() / .any()\n\t *   Promise.some() / .some()\n\t *   Promise.race() / .race()\n\t */\n\n\tshimBoth('map', [0]);\n\tshimBoth('filter', [0]);\n\tshimBoth('reduce', [0]);\n\tshimBoth('each', [0]);\n\n\t// In bluebird v2, there is no `Promise.mapSeries()`/`.mapSeries()` method\n\tif (v3) shimBoth('mapSeries', [0]);\n\n\t/*\n\t * Resource management\n\t *\n\t * NB disposer callbacks are bound to context at time disposer created, not when utilized in `using()`\n\t */\n\n\tshimUsing(Promise, ns, v3); // shims `Promise.using()`\n\tshimProto('disposer', [0]);\n\n\t/*\n\t * Promisification\n\t *\n\t * Not patched as always run callback synchronously:\n\t *   Promise.fromCallback()\n\t *   Promise.fromNode()\n\t *\n\t * Not patched as they are wrappers:\n\t *   Promise.promisify()\n\t *   Promise.promisifyAll()\n\t */\n\n\tshimProto('asCallback', [0]);\n\tPromise.prototype.nodeify = Promise.prototype.asCallback;\n\n\t/*\n\t * Timers\n\t *\n\t * Not patched as do not take a callback:\n\t *   Promise.delay() / .delay()\n\t *   .timeout()\n\t */\n\n\t/*\n\t * Cancellation\n\t *\n\t * Not patched as does not take a callback:\n\t *   .cancel() / .break()\n\t *   .isCancellable()\n\t *   .cancellable() (bluebird v2 only)\n\t *   .uncancellable() (bluebird v2 only)\n\t *\n\t * NB In bluebird v3 `onCancel` handler will be called\n\t * in CLS context of call to `onCancel()`.\n\t */\n\n\t// Patch `Promise.prototype._resolveFromExecutor`\n\t// in order to patch `onCancel` handler in `new Promise()`.\n\tif (v3) shimOnCancel(Promise, ns);\n\n\t/*\n\t * Generators\n\t *\n\t * Not patched as does not take a callback:\n\t *   Promise.coroutine.addYieldHandler()\n\t *\n\t * NB `options.yieldHandler` will run in whatever CLS context is active at time of `yield`\n\t */\n\n\tvar addYieldHandler = Promise.coroutine.addYieldHandler;\n\tshimCoroutine('coroutine', Promise, ns, v3); // shims `Promise.coroutine()`\n\tPromise.coroutine.addYieldHandler = addYieldHandler;\n\n\t/*\n\t * Utility\n\t *\n\t * Not patched as do not take a callback:\n\t *   .get()\n\t *   .return() / .thenReturn()\n\t *   .throw() / .thenThrow()\n\t *   .catchReturn()\n\t *   .catchThrow()\n\t *   Promise.getNewLibraryCopy()\n\t *   Promise.noConflict()\n\t *   Promise.setScheduler()\n\t */\n\n\tshimProto('tap', [0]);\n\tif (v3) shimProto('tapCatch', [-1]);\n\tshimCall(Promise, ns); // shims `.call()`\n\n\t/*\n\t * Configuration\n\t *\n\t * Not patched as do not take a callback:\n\t *   Promise.config()\n\t *   .suppressUnhandledRejections()\n\t *   Promise.longStackTraces()\n\t *   Promise.hasLongStackTraces()\n\t *\n\t * Not patched as meaningless to do so:\n\t *   Promise.onPossiblyUnhandledRejection()\n\t *   Promise.onUnhandledRejectionHandled()\n\t *\n\t * NB Error handlers will run with unknown CLS context.\n\t * CLS context should not be relied upon to be the context at the time error was thrown.\n\t * Catch errors with `.catch()` instead!\n\t */\n\n\tshimProto('done', v3 ? [0, 1] : [0, 1, 2]);\n\n\t/*\n\t * Progression (bluebird v2 only)\n\t */\n\n\tif (!v3) shimProto('progressed', [0]);\n\n\t/*\n\t * Undocumented\n\t *\n\t * Not patched as do not take a callback:\n\t *   Promise.is()\n\t *   Promise.settle() / .settle()\n\t *   Promise.defer() / Promise.pending()\n\t *   .toString()\n\t *   .toJSON()\n\t */\n\n\t// `.fork()` does not exist in bluebird v3\n\tif (!v3) shimProto('fork', [0, 1, 2]);\n\n\tshimCoroutine('spawn', Promise, ns, v3); // shims `Promise.spawn()`\n\n\t// Return patched Bluebird constructor\n\treturn Promise;\n\n\t/*\n\t * Patching functions\n\t */\n\tfunction shimStatic(methodName, args) {\n\t\tshimMethod(Promise, methodName, args, ns);\n\t}\n\n\tfunction shimProto(methodName, args) {\n\t\tshimMethod(Promise.prototype, methodName, args, ns);\n\t}\n\n\tfunction shimBoth(methodName, args) {\n\t\tshimProto(methodName, args);\n\t\tshimStatic(methodName, args.map(function(arg) { return arg < 0 ? arg : arg + 1; }));\n\t}\n};\n"]}