{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../source/utils/delay.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAO5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAClC,EAAU,EACV,EAAC,MAAM,EAAe;IAEtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,IAAI,MAAM,EAAE;YACX,IAAI,MAAM,CAAC,OAAO,EAAE;gBACnB,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAClC,OAAO;aACP;YAED,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;SAC5D;QAED,SAAS,WAAW;YACnB,MAAM,CAAC,iBAAiB,CAAC,MAAO,CAAC,CAAC,CAAC;YACnC,YAAY,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,EAAE,CAAC;QACX,CAAC,EAAE,EAAE,CAAC,CAAC;IACR,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {composeAbortError} from '../errors/DOMException.js';\nimport {InternalOptions} from '../types/options.js';\n\nexport interface DelayOptions {\n\tsignal?: InternalOptions['signal'];\n}\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tif (signal.aborted) {\n\t\t\t\treject(composeAbortError(signal));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsignal.addEventListener('abort', handleAbort, {once: true});\n\t\t}\n\n\t\tfunction handleAbort() {\n\t\t\treject(composeAbortError(signal!));\n\t\t\tclearTimeout(timeoutId);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', handleAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n"]}