c12abaf70128376bc1b5d489ba3f2485c0085e9fc38c35b3d4ab7af5feb30b62.json 4.5 KB

1
  1. {"ast":null,"code":"'use strict';\n\nconst pFinally = require('p-finally');\nclass TimeoutError extends Error {\n constructor(message) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\nconst pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reject) => {\n if (typeof milliseconds !== 'number' || milliseconds < 0) {\n throw new TypeError('Expected `milliseconds` to be a positive number');\n }\n if (milliseconds === Infinity) {\n resolve(promise);\n return;\n }\n const timer = setTimeout(() => {\n if (typeof fallback === 'function') {\n try {\n resolve(fallback());\n } catch (error) {\n reject(error);\n }\n return;\n }\n const message = typeof fallback === 'string' ? fallback : `Promise timed out after ${milliseconds} milliseconds`;\n const timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);\n if (typeof promise.cancel === 'function') {\n promise.cancel();\n }\n reject(timeoutError);\n }, milliseconds);\n\n // TODO: Use native `finally` keyword when targeting Node.js 10\n pFinally(\n // eslint-disable-next-line promise/prefer-await-to-then\n promise.then(resolve, reject), () => {\n clearTimeout(timer);\n });\n});\nmodule.exports = pTimeout;\n// TODO: Remove this for the next major release\nmodule.exports.default = pTimeout;\nmodule.exports.TimeoutError = TimeoutError;","map":{"version":3,"names":["pFinally","require","TimeoutError","Error","constructor","message","name","pTimeout","promise","milliseconds","fallback","Promise","resolve","reject","TypeError","Infinity","timer","setTimeout","error","timeoutError","cancel","then","clearTimeout","module","exports","default"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/p-timeout/index.js"],"sourcesContent":["'use strict';\n\nconst pFinally = require('p-finally');\n\nclass TimeoutError extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = 'TimeoutError';\n\t}\n}\n\nconst pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reject) => {\n\tif (typeof milliseconds !== 'number' || milliseconds < 0) {\n\t\tthrow new TypeError('Expected `milliseconds` to be a positive number');\n\t}\n\n\tif (milliseconds === Infinity) {\n\t\tresolve(promise);\n\t\treturn;\n\t}\n\n\tconst timer = setTimeout(() => {\n\t\tif (typeof fallback === 'function') {\n\t\t\ttry {\n\t\t\t\tresolve(fallback());\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst message = typeof fallback === 'string' ? fallback : `Promise timed out after ${milliseconds} milliseconds`;\n\t\tconst timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);\n\n\t\tif (typeof promise.cancel === 'function') {\n\t\t\tpromise.cancel();\n\t\t}\n\n\t\treject(timeoutError);\n\t}, milliseconds);\n\n\t// TODO: Use native `finally` keyword when targeting Node.js 10\n\tpFinally(\n\t\t// eslint-disable-next-line promise/prefer-await-to-then\n\t\tpromise.then(resolve, reject),\n\t\t() => {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t);\n});\n\nmodule.exports = pTimeout;\n// TODO: Remove this for the next major release\nmodule.exports.default = pTimeout;\n\nmodule.exports.TimeoutError = TimeoutError;\n"],"mappings":"AAAA,YAAY;;AAEZ,MAAMA,QAAQ,GAAGC,OAAO,CAAC,WAAW,CAAC;AAErC,MAAMC,YAAY,SAASC,KAAK,CAAC;EAChCC,WAAWA,CAACC,OAAO,EAAE;IACpB,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC3B;AACD;AAEA,MAAMC,QAAQ,GAAGA,CAACC,OAAO,EAAEC,YAAY,EAAEC,QAAQ,KAAK,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;EACtF,IAAI,OAAOJ,YAAY,KAAK,QAAQ,IAAIA,YAAY,GAAG,CAAC,EAAE;IACzD,MAAM,IAAIK,SAAS,CAAC,iDAAiD,CAAC;EACvE;EAEA,IAAIL,YAAY,KAAKM,QAAQ,EAAE;IAC9BH,OAAO,CAACJ,OAAO,CAAC;IAChB;EACD;EAEA,MAAMQ,KAAK,GAAGC,UAAU,C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