UNPKG

1.2 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/defer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,aAAiB,SAAQ,SAAY;IAGzC,YAAY,EAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE;YAC7B,MAAM,IAAI,CAAC;SACZ;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAU,OAAgC;IAC7D,OAAO,IAAI,aAAa,CAAU,OAAO,CAAC,CAAC;AAC7C,CAAC","file":"defer.js","sourcesContent":["import { IterableX } from './iterablex';\n\nclass DeferIterable<T> extends IterableX<T> {\n private _fn: () => Iterable<T>;\n\n constructor(fn: () => Iterable<T>) {\n super();\n this._fn = fn;\n }\n\n *[Symbol.iterator]() {\n for (const item of this._fn()) {\n yield item;\n }\n }\n}\n\n/**\n * Creates an enumerable sequence based on an iterable factory function.\n * @param {function(): Iterable<T>} factory Iterable factory function.\n * @return {Iterable<T>} Sequence that will invoke the iterable factory upon a call to [Symbol.iterator]().\n */\nexport function defer<TSource>(factory: () => Iterable<TSource>): IterableX<TSource> {\n return new DeferIterable<TSource>(factory);\n}\n"]}
\No newline at end of file