@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
1 lines • 2.28 kB
Source Map (JSON)
{"version":3,"sources":["asynciterable/operators/delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,kBAA4B,SAAQ,cAAuB;IAItE,YAAY,MAA8B,EAAE,OAAe;QACzD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAoB;QAChD,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;YAC5D,MAAM,IAAI,CAAC;SACZ;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAU,OAAe;IAC5C,OAAO,SAAS,qBAAqB,CAAC,MAA8B;QAClE,OAAO,IAAI,kBAAkB,CAAU,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC","file":"delay.js","sourcesContent":["import { AsyncIterableX } from '../asynciterablex';\nimport { MonoTypeOperatorAsyncFunction } from '../../interfaces';\nimport { sleep } from '../_sleep';\nimport { wrapWithAbort } from './withabort';\nimport { throwIfAborted } from '../../aborterror';\n\nexport class DelayAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: AsyncIterable<TSource>;\n private _dueTime: number;\n\n constructor(source: AsyncIterable<TSource>, dueTime: number) {\n super();\n this._source = source;\n this._dueTime = dueTime;\n }\n\n async *[Symbol.asyncIterator](signal?: AbortSignal) {\n throwIfAborted(signal);\n await sleep(this._dueTime, signal);\n for await (const item of wrapWithAbort(this._source, signal)) {\n yield item;\n }\n }\n}\n\n/**\n * Delays the emitting of the first item in the async-iterable by the given due time.\n *\n * @export\n * @template TSource The type of elements in the source sequence.\n * @param {number} dueTime The delay duration in milliseconds\n * @returns {MonoTypeOperatorAsyncFunction<TSource>} An operator which delays the before the iteration begins.\n */\nexport function delay<TSource>(dueTime: number): MonoTypeOperatorAsyncFunction<TSource> {\n return function delayOperatorFunction(source: AsyncIterable<TSource>): AsyncIterableX<TSource> {\n return new DelayAsyncIterable<TSource>(source, dueTime);\n };\n}\n"]}