UNPKG

1.39 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/delayeach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,OAAO,sBAAgC,SAAQ,cAAuB;IAI1E,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;QAC3B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YACrC,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC3B,MAAM,IAAI,CAAC;SACZ;IACH,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CACvB,MAA8B,EAC9B,OAAe;IAEf,OAAO,IAAI,sBAAsB,CAAU,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC","file":"delayeach.js","sourcesContent":["import { AsyncIterableX } from './asynciterablex';\nimport { sleep } from './_sleep';\n\nexport class DelayEachAsyncIterable<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]() {\n for await (const item of this._source) {\n await sleep(this._dueTime);\n yield item;\n }\n }\n}\n\nexport function delayEach<TSource>(\n source: AsyncIterable<TSource>,\n dueTime: number\n): AsyncIterableX<TSource> {\n return new DelayEachAsyncIterable<TSource>(source, dueTime);\n}\n"]}
\No newline at end of file