iter-fest 0.1.1-main.4decbaa → 0.1.1-main.57b2094
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -56
- package/dist/chunk-2DE3J4J7.mjs +35 -0
- package/dist/chunk-2DE3J4J7.mjs.map +1 -0
- package/dist/chunk-3S6LCGE6.mjs +10 -0
- package/dist/chunk-3S6LCGE6.mjs.map +1 -0
- package/dist/{chunk-UIEKIMLW.mjs → chunk-AN54W42O.mjs} +8 -5
- package/dist/chunk-AN54W42O.mjs.map +1 -0
- package/dist/chunk-ANRVAYLW.mjs +35 -0
- package/dist/chunk-ANRVAYLW.mjs.map +1 -0
- package/dist/chunk-BSAPKNNZ.mjs +16 -0
- package/dist/chunk-BSAPKNNZ.mjs.map +1 -0
- package/dist/chunk-BWMXKULC.mjs +46 -0
- package/dist/chunk-BWMXKULC.mjs.map +1 -0
- package/dist/chunk-CNCNQPK3.mjs +16 -0
- package/dist/chunk-CNCNQPK3.mjs.map +1 -0
- package/dist/{chunk-KONB7TV6.mjs → chunk-EQZQP6GW.mjs} +8 -5
- package/dist/chunk-EQZQP6GW.mjs.map +1 -0
- package/dist/{chunk-2HLJODU3.mjs → chunk-EUVK4YM7.mjs} +8 -4
- package/dist/chunk-EUVK4YM7.mjs.map +1 -0
- package/dist/chunk-FBST4AUL.mjs +10 -0
- package/dist/chunk-FBST4AUL.mjs.map +1 -0
- package/dist/chunk-FEEBFWAI.mjs +24 -0
- package/dist/chunk-FEEBFWAI.mjs.map +1 -0
- package/dist/chunk-FMIHIL6A.mjs +10 -0
- package/dist/chunk-FMIHIL6A.mjs.map +1 -0
- package/dist/{chunk-27NJVC7K.mjs → chunk-H27CTQGV.mjs} +8 -5
- package/dist/chunk-H27CTQGV.mjs.map +1 -0
- package/dist/{chunk-MDBK7ND5.mjs → chunk-H5ARVU55.mjs} +8 -5
- package/dist/chunk-H5ARVU55.mjs.map +1 -0
- package/dist/{chunk-WKIRSZXX.mjs → chunk-IZXDQ25M.mjs} +8 -5
- package/dist/chunk-IZXDQ25M.mjs.map +1 -0
- package/dist/chunk-KYMTQJIJ.mjs +10 -0
- package/dist/chunk-KYMTQJIJ.mjs.map +1 -0
- package/dist/chunk-LIMQXDFK.mjs +10 -0
- package/dist/chunk-LIMQXDFK.mjs.map +1 -0
- package/dist/chunk-MO7HMLOZ.mjs +24 -0
- package/dist/chunk-MO7HMLOZ.mjs.map +1 -0
- package/dist/chunk-MYSNSDM7.mjs +13 -0
- package/dist/chunk-MYSNSDM7.mjs.map +1 -0
- package/dist/chunk-NZRXO7EY.mjs +24 -0
- package/dist/chunk-NZRXO7EY.mjs.map +1 -0
- package/dist/chunk-OCK7PKGO.mjs +23 -0
- package/dist/chunk-OCK7PKGO.mjs.map +1 -0
- package/dist/chunk-OWUGLCQB.mjs +10 -0
- package/dist/chunk-OWUGLCQB.mjs.map +1 -0
- package/dist/chunk-P4OSZLEH.mjs +15 -0
- package/dist/chunk-P4OSZLEH.mjs.map +1 -0
- package/dist/chunk-PGJSIDLV.mjs +25 -0
- package/dist/chunk-PGJSIDLV.mjs.map +1 -0
- package/dist/chunk-QX6EMOSQ.mjs +10 -0
- package/dist/chunk-QX6EMOSQ.mjs.map +1 -0
- package/dist/chunk-R6SXIXMH.mjs +10 -0
- package/dist/chunk-R6SXIXMH.mjs.map +1 -0
- package/dist/chunk-TDHR35S7.mjs +10 -0
- package/dist/chunk-TDHR35S7.mjs.map +1 -0
- package/dist/chunk-VCKLUCOT.mjs +10 -0
- package/dist/chunk-VCKLUCOT.mjs.map +1 -0
- package/dist/chunk-XQDGXAAF.mjs +10 -0
- package/dist/chunk-XQDGXAAF.mjs.map +1 -0
- package/dist/chunk-YJSIVBF7.mjs +22 -0
- package/dist/chunk-YJSIVBF7.mjs.map +1 -0
- package/dist/chunk-YLERARWI.mjs +10 -0
- package/dist/chunk-YLERARWI.mjs.map +1 -0
- package/dist/iter-fest.asyncGeneratorWithLastValue.d.mts +6 -0
- package/dist/iter-fest.asyncGeneratorWithLastValue.d.ts +6 -0
- package/dist/iter-fest.asyncGeneratorWithLastValue.js +59 -0
- package/dist/iter-fest.asyncGeneratorWithLastValue.js.map +1 -0
- package/dist/iter-fest.asyncGeneratorWithLastValue.mjs +7 -0
- package/dist/iter-fest.asyncIteratorToAsyncIterable.d.mts +3 -0
- package/dist/iter-fest.asyncIteratorToAsyncIterable.d.ts +3 -0
- package/dist/{iter-fest.iterableConcat.js → iter-fest.asyncIteratorToAsyncIterable.js} +15 -16
- package/dist/iter-fest.asyncIteratorToAsyncIterable.js.map +1 -0
- package/dist/iter-fest.asyncIteratorToAsyncIterable.mjs +7 -0
- package/dist/iter-fest.d.mts +31 -23
- package/dist/iter-fest.d.ts +31 -23
- package/dist/iter-fest.generatorWithLastValue.d.mts +6 -0
- package/dist/iter-fest.generatorWithLastValue.d.ts +6 -0
- package/dist/iter-fest.generatorWithLastValue.js +59 -0
- package/dist/iter-fest.generatorWithLastValue.js.map +1 -0
- package/dist/iter-fest.generatorWithLastValue.mjs +7 -0
- package/dist/iter-fest.iterableWritableStream.d.mts +7 -0
- package/dist/iter-fest.iterableWritableStream.d.ts +7 -0
- package/dist/{iter-fest.pushAsyncIterableIterator.js → iter-fest.iterableWritableStream.js} +39 -30
- package/dist/iter-fest.iterableWritableStream.js.map +1 -0
- package/dist/iter-fest.iterableWritableStream.mjs +7 -0
- package/dist/{iter-fest.iterableAt.d.mts → iter-fest.iteratorAt.d.mts} +2 -2
- package/dist/{iter-fest.iterableAt.d.ts → iter-fest.iteratorAt.d.ts} +2 -2
- package/dist/{iter-fest.iterableAt.js → iter-fest.iteratorAt.js} +21 -10
- package/dist/iter-fest.iteratorAt.js.map +1 -0
- package/dist/iter-fest.iteratorAt.mjs +9 -0
- package/dist/iter-fest.iteratorConcat.d.mts +16 -0
- package/dist/iter-fest.iteratorConcat.d.ts +16 -0
- package/dist/iter-fest.iteratorConcat.js +56 -0
- package/dist/iter-fest.iteratorConcat.js.map +1 -0
- package/dist/iter-fest.iteratorConcat.mjs +8 -0
- package/dist/iter-fest.iteratorDrop.d.mts +12 -0
- package/dist/iter-fest.iteratorDrop.d.ts +12 -0
- package/dist/iter-fest.iteratorDrop.js +44 -0
- package/dist/iter-fest.iteratorDrop.js.map +1 -0
- package/dist/iter-fest.iteratorDrop.mjs +7 -0
- package/dist/iter-fest.iteratorEntries.d.mts +6 -0
- package/dist/iter-fest.iteratorEntries.d.ts +6 -0
- package/dist/{iter-fest.iterableEntries.js → iter-fest.iteratorEntries.js} +22 -9
- package/dist/iter-fest.iteratorEntries.js.map +1 -0
- package/dist/iter-fest.iteratorEntries.mjs +8 -0
- package/dist/iter-fest.iteratorEvery.d.mts +25 -0
- package/dist/iter-fest.iteratorEvery.d.ts +25 -0
- package/dist/iter-fest.iteratorEvery.js +44 -0
- package/dist/iter-fest.iteratorEvery.js.map +1 -0
- package/dist/iter-fest.iteratorEvery.mjs +7 -0
- package/dist/iter-fest.iteratorFilter.d.mts +18 -0
- package/dist/iter-fest.iteratorFilter.d.ts +18 -0
- package/dist/iter-fest.iteratorFilter.js +44 -0
- package/dist/iter-fest.iteratorFilter.js.map +1 -0
- package/dist/iter-fest.iteratorFilter.mjs +7 -0
- package/dist/iter-fest.iteratorFind.d.mts +14 -0
- package/dist/iter-fest.iteratorFind.d.ts +14 -0
- package/dist/iter-fest.iteratorFind.js +44 -0
- package/dist/iter-fest.iteratorFind.js.map +1 -0
- package/dist/iter-fest.iteratorFind.mjs +7 -0
- package/dist/{iter-fest.iterableFindIndex.d.mts → iter-fest.iteratorFindIndex.d.mts} +4 -4
- package/dist/{iter-fest.iterableFindIndex.d.ts → iter-fest.iteratorFindIndex.d.ts} +4 -4
- package/dist/{iter-fest.iterableFindIndex.js → iter-fest.iteratorFindIndex.js} +23 -10
- package/dist/iter-fest.iteratorFindIndex.js.map +1 -0
- package/dist/iter-fest.iteratorFindIndex.mjs +8 -0
- package/dist/{iter-fest.iterableFindLast.d.mts → iter-fest.iteratorFindLast.d.mts} +5 -5
- package/dist/{iter-fest.iterableFindLast.d.ts → iter-fest.iteratorFindLast.d.ts} +5 -5
- package/dist/{iter-fest.iterableFindLast.js → iter-fest.iteratorFindLast.js} +23 -10
- package/dist/iter-fest.iteratorFindLast.js.map +1 -0
- package/dist/iter-fest.iteratorFindLast.mjs +8 -0
- package/dist/{iter-fest.iterableFindLastIndex.d.mts → iter-fest.iteratorFindLastIndex.d.mts} +4 -4
- package/dist/{iter-fest.iterableFindLastIndex.d.ts → iter-fest.iteratorFindLastIndex.d.ts} +4 -4
- package/dist/{iter-fest.iterableFindLastIndex.js → iter-fest.iteratorFindLastIndex.js} +23 -10
- package/dist/iter-fest.iteratorFindLastIndex.js.map +1 -0
- package/dist/iter-fest.iteratorFindLastIndex.mjs +8 -0
- package/dist/iter-fest.iteratorFlatMap.d.mts +12 -0
- package/dist/iter-fest.iteratorFlatMap.d.ts +12 -0
- package/dist/iter-fest.iteratorFlatMap.js +44 -0
- package/dist/iter-fest.iteratorFlatMap.js.map +1 -0
- package/dist/iter-fest.iteratorFlatMap.mjs +7 -0
- package/dist/iter-fest.iteratorForEach.d.mts +10 -0
- package/dist/iter-fest.iteratorForEach.d.ts +10 -0
- package/dist/iter-fest.iteratorForEach.js +44 -0
- package/dist/iter-fest.iteratorForEach.js.map +1 -0
- package/dist/iter-fest.iteratorForEach.mjs +7 -0
- package/dist/iter-fest.iteratorFrom.d.mts +12 -0
- package/dist/iter-fest.iteratorFrom.d.ts +12 -0
- package/dist/iter-fest.iteratorFrom.js +44 -0
- package/dist/iter-fest.iteratorFrom.js.map +1 -0
- package/dist/iter-fest.iteratorFrom.mjs +7 -0
- package/dist/iter-fest.iteratorIncludes.d.mts +9 -0
- package/dist/iter-fest.iteratorIncludes.d.ts +9 -0
- package/dist/{iter-fest.iterableIncludes.js → iter-fest.iteratorIncludes.js} +21 -10
- package/dist/iter-fest.iteratorIncludes.js.map +1 -0
- package/dist/iter-fest.iteratorIncludes.mjs +9 -0
- package/dist/iter-fest.iteratorIndexOf.d.mts +9 -0
- package/dist/iter-fest.iteratorIndexOf.d.ts +9 -0
- package/dist/{iter-fest.iterableIndexOf.js → iter-fest.iteratorIndexOf.js} +21 -10
- package/dist/iter-fest.iteratorIndexOf.js.map +1 -0
- package/dist/iter-fest.iteratorIndexOf.mjs +9 -0
- package/dist/iter-fest.iteratorJoin.d.mts +8 -0
- package/dist/iter-fest.iteratorJoin.d.ts +8 -0
- package/dist/{iter-fest.iterableToString.js → iter-fest.iteratorJoin.js} +21 -15
- package/dist/iter-fest.iteratorJoin.js.map +1 -0
- package/dist/iter-fest.iteratorJoin.mjs +8 -0
- package/dist/iter-fest.iteratorKeys.d.mts +6 -0
- package/dist/iter-fest.iteratorKeys.d.ts +6 -0
- package/dist/{iter-fest.iterableKeys.js → iter-fest.iteratorKeys.js} +22 -9
- package/dist/iter-fest.iteratorKeys.js.map +1 -0
- package/dist/iter-fest.iteratorKeys.mjs +8 -0
- package/dist/iter-fest.iteratorMap.d.mts +10 -0
- package/dist/iter-fest.iteratorMap.d.ts +10 -0
- package/dist/iter-fest.iteratorMap.js +44 -0
- package/dist/iter-fest.iteratorMap.js.map +1 -0
- package/dist/iter-fest.iteratorMap.mjs +7 -0
- package/dist/{iter-fest.iterableReduce.d.mts → iter-fest.iteratorReduce.d.mts} +13 -9
- package/dist/{iter-fest.iterableReduce.d.ts → iter-fest.iteratorReduce.d.ts} +13 -9
- package/dist/iter-fest.iteratorReduce.js +44 -0
- package/dist/iter-fest.iteratorReduce.js.map +1 -0
- package/dist/iter-fest.iteratorReduce.mjs +7 -0
- package/dist/{iter-fest.iterableSlice.d.mts → iter-fest.iteratorSlice.d.mts} +8 -8
- package/dist/{iter-fest.iterableSlice.d.ts → iter-fest.iteratorSlice.d.ts} +8 -8
- package/dist/{iter-fest.iterableSlice.js → iter-fest.iteratorSlice.js} +21 -10
- package/dist/iter-fest.iteratorSlice.js.map +1 -0
- package/dist/iter-fest.iteratorSlice.mjs +9 -0
- package/dist/iter-fest.iteratorSlice.mjs.map +1 -0
- package/dist/iter-fest.iteratorSome.d.mts +10 -0
- package/dist/iter-fest.iteratorSome.d.ts +10 -0
- package/dist/iter-fest.iteratorSome.js +44 -0
- package/dist/iter-fest.iteratorSome.js.map +1 -0
- package/dist/iter-fest.iteratorSome.mjs +7 -0
- package/dist/iter-fest.iteratorSome.mjs.map +1 -0
- package/dist/iter-fest.iteratorTake.d.mts +12 -0
- package/dist/iter-fest.iteratorTake.d.ts +12 -0
- package/dist/iter-fest.iteratorTake.js +44 -0
- package/dist/iter-fest.iteratorTake.js.map +1 -0
- package/dist/iter-fest.iteratorTake.mjs +7 -0
- package/dist/iter-fest.iteratorTake.mjs.map +1 -0
- package/dist/iter-fest.iteratorToArray.d.mts +13 -0
- package/dist/iter-fest.iteratorToArray.d.ts +13 -0
- package/dist/iter-fest.iteratorToArray.js +44 -0
- package/dist/iter-fest.iteratorToArray.js.map +1 -0
- package/dist/iter-fest.iteratorToArray.mjs +7 -0
- package/dist/iter-fest.iteratorToArray.mjs.map +1 -0
- package/dist/{iter-fest.iterableToSpliced.d.mts → iter-fest.iteratorToSpliced.d.mts} +3 -3
- package/dist/{iter-fest.iterableToSpliced.d.ts → iter-fest.iteratorToSpliced.d.ts} +3 -3
- package/dist/{iter-fest.iterableToSpliced.js → iter-fest.iteratorToSpliced.js} +21 -10
- package/dist/iter-fest.iteratorToSpliced.js.map +1 -0
- package/dist/iter-fest.iteratorToSpliced.mjs +9 -0
- package/dist/iter-fest.iteratorToSpliced.mjs.map +1 -0
- package/dist/iter-fest.iteratorToString.d.mts +6 -0
- package/dist/iter-fest.iteratorToString.d.ts +6 -0
- package/dist/{iter-fest.iterableJoin.js → iter-fest.iteratorToString.js} +27 -9
- package/dist/iter-fest.iteratorToString.js.map +1 -0
- package/dist/iter-fest.iteratorToString.mjs +9 -0
- package/dist/iter-fest.iteratorToString.mjs.map +1 -0
- package/dist/iter-fest.js +335 -289
- package/dist/iter-fest.js.map +1 -1
- package/dist/iter-fest.mjs +108 -77
- package/dist/iter-fest.readableStreamFrom.d.mts +3 -0
- package/dist/iter-fest.readableStreamFrom.d.ts +3 -0
- package/dist/{iter-fest.iterableFilter.js → iter-fest.readableStreamFrom.js} +21 -17
- package/dist/iter-fest.readableStreamFrom.js.map +1 -0
- package/dist/iter-fest.readableStreamFrom.mjs +7 -0
- package/dist/iter-fest.readableStreamFrom.mjs.map +1 -0
- package/dist/iter-fest.readerValues.d.mts +3 -0
- package/dist/iter-fest.readerValues.d.ts +3 -0
- package/dist/{iter-fest.readerToAsyncIterableIterator.js → iter-fest.readerValues.js} +12 -8
- package/dist/iter-fest.readerValues.js.map +1 -0
- package/dist/iter-fest.readerValues.mjs +7 -0
- package/dist/iter-fest.readerValues.mjs.map +1 -0
- package/package.json +207 -127
- package/dist/chunk-27NJVC7K.mjs.map +0 -1
- package/dist/chunk-2HLJODU3.mjs.map +0 -1
- package/dist/chunk-44W7OTNE.mjs +0 -12
- package/dist/chunk-44W7OTNE.mjs.map +0 -1
- package/dist/chunk-4LRYDU2Y.mjs +0 -62
- package/dist/chunk-4LRYDU2Y.mjs.map +0 -1
- package/dist/chunk-5CHMNKXJ.mjs +0 -20
- package/dist/chunk-5CHMNKXJ.mjs.map +0 -1
- package/dist/chunk-5CRMPYKD.mjs +0 -19
- package/dist/chunk-5CRMPYKD.mjs.map +0 -1
- package/dist/chunk-6C3P4TNK.mjs +0 -19
- package/dist/chunk-6C3P4TNK.mjs.map +0 -1
- package/dist/chunk-EZC33HE6.mjs +0 -15
- package/dist/chunk-EZC33HE6.mjs.map +0 -1
- package/dist/chunk-GWZF5BB7.mjs +0 -16
- package/dist/chunk-GWZF5BB7.mjs.map +0 -1
- package/dist/chunk-HYU4EN7J.mjs +0 -20
- package/dist/chunk-HYU4EN7J.mjs.map +0 -1
- package/dist/chunk-JU353VSE.mjs +0 -16
- package/dist/chunk-JU353VSE.mjs.map +0 -1
- package/dist/chunk-K5XV4W7G.mjs +0 -35
- package/dist/chunk-K5XV4W7G.mjs.map +0 -1
- package/dist/chunk-KONB7TV6.mjs.map +0 -1
- package/dist/chunk-MDBK7ND5.mjs.map +0 -1
- package/dist/chunk-MNLOWKTC.mjs +0 -19
- package/dist/chunk-MNLOWKTC.mjs.map +0 -1
- package/dist/chunk-TEI3K6GT.mjs +0 -21
- package/dist/chunk-TEI3K6GT.mjs.map +0 -1
- package/dist/chunk-U6G4RNZ2.mjs +0 -10
- package/dist/chunk-U6G4RNZ2.mjs.map +0 -1
- package/dist/chunk-UIEKIMLW.mjs.map +0 -1
- package/dist/chunk-V6OWQQ3Q.mjs +0 -20
- package/dist/chunk-V6OWQQ3Q.mjs.map +0 -1
- package/dist/chunk-WKIRSZXX.mjs.map +0 -1
- package/dist/chunk-XKBVB2JN.mjs +0 -12
- package/dist/chunk-XKBVB2JN.mjs.map +0 -1
- package/dist/chunk-XW34KZRY.mjs +0 -17
- package/dist/chunk-XW34KZRY.mjs.map +0 -1
- package/dist/chunk-Y5M2C7NQ.mjs +0 -13
- package/dist/chunk-Y5M2C7NQ.mjs.map +0 -1
- package/dist/chunk-ZUBHGSCW.mjs +0 -18
- package/dist/chunk-ZUBHGSCW.mjs.map +0 -1
- package/dist/iter-fest.iterableAt.js.map +0 -1
- package/dist/iter-fest.iterableAt.mjs +0 -8
- package/dist/iter-fest.iterableConcat.d.mts +0 -16
- package/dist/iter-fest.iterableConcat.d.ts +0 -16
- package/dist/iter-fest.iterableConcat.js.map +0 -1
- package/dist/iter-fest.iterableConcat.mjs +0 -7
- package/dist/iter-fest.iterableEntries.d.mts +0 -6
- package/dist/iter-fest.iterableEntries.d.ts +0 -6
- package/dist/iter-fest.iterableEntries.js.map +0 -1
- package/dist/iter-fest.iterableEntries.mjs +0 -7
- package/dist/iter-fest.iterableEvery.d.mts +0 -24
- package/dist/iter-fest.iterableEvery.d.ts +0 -24
- package/dist/iter-fest.iterableEvery.js +0 -43
- package/dist/iter-fest.iterableEvery.js.map +0 -1
- package/dist/iter-fest.iterableEvery.mjs +0 -7
- package/dist/iter-fest.iterableFilter.d.mts +0 -16
- package/dist/iter-fest.iterableFilter.d.ts +0 -16
- package/dist/iter-fest.iterableFilter.js.map +0 -1
- package/dist/iter-fest.iterableFilter.mjs +0 -7
- package/dist/iter-fest.iterableFind.d.mts +0 -15
- package/dist/iter-fest.iterableFind.d.ts +0 -15
- package/dist/iter-fest.iterableFind.js +0 -43
- package/dist/iter-fest.iterableFind.js.map +0 -1
- package/dist/iter-fest.iterableFind.mjs +0 -7
- package/dist/iter-fest.iterableFindIndex.js.map +0 -1
- package/dist/iter-fest.iterableFindIndex.mjs +0 -7
- package/dist/iter-fest.iterableFindLast.js.map +0 -1
- package/dist/iter-fest.iterableFindLast.mjs +0 -7
- package/dist/iter-fest.iterableFindLastIndex.js.map +0 -1
- package/dist/iter-fest.iterableFindLastIndex.mjs +0 -7
- package/dist/iter-fest.iterableForEach.d.mts +0 -10
- package/dist/iter-fest.iterableForEach.d.ts +0 -10
- package/dist/iter-fest.iterableForEach.js +0 -40
- package/dist/iter-fest.iterableForEach.js.map +0 -1
- package/dist/iter-fest.iterableForEach.mjs +0 -7
- package/dist/iter-fest.iterableIncludes.d.mts +0 -9
- package/dist/iter-fest.iterableIncludes.d.ts +0 -9
- package/dist/iter-fest.iterableIncludes.js.map +0 -1
- package/dist/iter-fest.iterableIncludes.mjs +0 -8
- package/dist/iter-fest.iterableIndexOf.d.mts +0 -9
- package/dist/iter-fest.iterableIndexOf.d.ts +0 -9
- package/dist/iter-fest.iterableIndexOf.js.map +0 -1
- package/dist/iter-fest.iterableIndexOf.mjs +0 -8
- package/dist/iter-fest.iterableJoin.d.mts +0 -8
- package/dist/iter-fest.iterableJoin.d.ts +0 -8
- package/dist/iter-fest.iterableJoin.js.map +0 -1
- package/dist/iter-fest.iterableJoin.mjs +0 -7
- package/dist/iter-fest.iterableKeys.d.mts +0 -6
- package/dist/iter-fest.iterableKeys.d.ts +0 -6
- package/dist/iter-fest.iterableKeys.js.map +0 -1
- package/dist/iter-fest.iterableKeys.mjs +0 -7
- package/dist/iter-fest.iterableMap.d.mts +0 -8
- package/dist/iter-fest.iterableMap.d.ts +0 -8
- package/dist/iter-fest.iterableMap.js +0 -39
- package/dist/iter-fest.iterableMap.js.map +0 -1
- package/dist/iter-fest.iterableMap.mjs +0 -7
- package/dist/iter-fest.iterableReduce.js +0 -41
- package/dist/iter-fest.iterableReduce.js.map +0 -1
- package/dist/iter-fest.iterableReduce.mjs +0 -7
- package/dist/iter-fest.iterableSlice.js.map +0 -1
- package/dist/iter-fest.iterableSlice.mjs +0 -8
- package/dist/iter-fest.iterableSome.d.mts +0 -12
- package/dist/iter-fest.iterableSome.d.ts +0 -12
- package/dist/iter-fest.iterableSome.js +0 -43
- package/dist/iter-fest.iterableSome.js.map +0 -1
- package/dist/iter-fest.iterableSome.mjs +0 -7
- package/dist/iter-fest.iterableToSpliced.js.map +0 -1
- package/dist/iter-fest.iterableToSpliced.mjs +0 -8
- package/dist/iter-fest.iterableToString.d.mts +0 -6
- package/dist/iter-fest.iterableToString.d.ts +0 -6
- package/dist/iter-fest.iterableToString.js.map +0 -1
- package/dist/iter-fest.iterableToString.mjs +0 -8
- package/dist/iter-fest.observableValues.d.mts +0 -7
- package/dist/iter-fest.observableValues.d.ts +0 -7
- package/dist/iter-fest.observableValues.js +0 -100
- package/dist/iter-fest.observableValues.js.map +0 -1
- package/dist/iter-fest.observableValues.mjs +0 -8
- package/dist/iter-fest.pushAsyncIterableIterator.d.mts +0 -9
- package/dist/iter-fest.pushAsyncIterableIterator.d.ts +0 -9
- package/dist/iter-fest.pushAsyncIterableIterator.js.map +0 -1
- package/dist/iter-fest.pushAsyncIterableIterator.mjs +0 -8
- package/dist/iter-fest.readerToAsyncIterableIterator.d.mts +0 -3
- package/dist/iter-fest.readerToAsyncIterableIterator.d.ts +0 -3
- package/dist/iter-fest.readerToAsyncIterableIterator.js.map +0 -1
- package/dist/iter-fest.readerToAsyncIterableIterator.mjs +0 -7
- /package/dist/{iter-fest.iterableAt.mjs.map → iter-fest.asyncGeneratorWithLastValue.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableConcat.mjs.map → iter-fest.asyncIteratorToAsyncIterable.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableEntries.mjs.map → iter-fest.generatorWithLastValue.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableEvery.mjs.map → iter-fest.iterableWritableStream.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFilter.mjs.map → iter-fest.iteratorAt.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFind.mjs.map → iter-fest.iteratorConcat.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindIndex.mjs.map → iter-fest.iteratorDrop.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindLast.mjs.map → iter-fest.iteratorEntries.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindLastIndex.mjs.map → iter-fest.iteratorEvery.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableForEach.mjs.map → iter-fest.iteratorFilter.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableIncludes.mjs.map → iter-fest.iteratorFind.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableIndexOf.mjs.map → iter-fest.iteratorFindIndex.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableJoin.mjs.map → iter-fest.iteratorFindLast.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableKeys.mjs.map → iter-fest.iteratorFindLastIndex.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableMap.mjs.map → iter-fest.iteratorFlatMap.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableReduce.mjs.map → iter-fest.iteratorForEach.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableSlice.mjs.map → iter-fest.iteratorFrom.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableSome.mjs.map → iter-fest.iteratorIncludes.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableToSpliced.mjs.map → iter-fest.iteratorIndexOf.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableToString.mjs.map → iter-fest.iteratorJoin.mjs.map} +0 -0
- /package/dist/{iter-fest.observableValues.mjs.map → iter-fest.iteratorKeys.mjs.map} +0 -0
- /package/dist/{iter-fest.pushAsyncIterableIterator.mjs.map → iter-fest.iteratorMap.mjs.map} +0 -0
- /package/dist/{iter-fest.readerToAsyncIterableIterator.mjs.map → iter-fest.iteratorReduce.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -16,26 +16,22 @@ Iterables can contains infinite number of items, please use this package respons
|
|
|
16
16
|
npm install iter-fest
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Conversions
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
| From | To | Function signature |
|
|
22
|
+
| ----------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `Iterator` | `IterableIterator` | [`iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T>`](#converting-an-iterator-to-iterable) |
|
|
24
|
+
| `AsyncIterator` | `AsyncIterableIterator` | [`asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>`](#converting-an-iterator-to-iterable) |
|
|
25
|
+
| `Observable` | `ReadableStream` | [`observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>`](#converting-an-observable-to-readablestream) |
|
|
26
|
+
| `ReadableStreamDefaultReader` | `AsyncIterableIterator` | [`readerValues`<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T>`](#converting-a-readablestreamdefaultreader-to-asynciterableiterator) |
|
|
27
|
+
| `AsyncIterable` | `Observable` | [`observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>`](#converting-an-asynciterable-to-observable) |
|
|
28
|
+
| `AsyncIterable`/`Iterable` | `ReadableStream` | [`readableStreamFrom<T>(anyIterable: AsyncIterable<T> \| Iterable<T>): ReadableStream<T>`](#converting-an-asynciterableiterable-to-readablestream) |
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
import { iterableIncludes, iterableReduce } from 'iter-fest'; // Via default exports.
|
|
25
|
-
import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
|
|
26
|
-
|
|
27
|
-
const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
|
|
28
|
-
|
|
29
|
-
console.log(iterableIncludes(iterable, 3)); // Prints "true".
|
|
30
|
-
console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
|
|
31
|
-
console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`every`](https://tc39.es/ecma262/#sec-array.prototype.every), [`filter`](https://tc39.es/ecma262/#sec-array.prototype.filter), [`find`](https://tc39.es/ecma262/#sec-array.prototype.find), [`findIndex`](https://tc39.es/ecma262/#sec-array.prototype.findindex), [`findLast`](https://tc39.es/ecma262/#sec-array.prototype.findlast), [`findLastIndex`](https://tc39.es/ecma262/#sec-array.prototype.findlastindex), [`forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach), [`includes`](https://tc39.es/ecma262/#sec-array.prototype.includes), [`indexOf`](https://tc39.es/ecma262/#sec-array.prototype.indexof), [`join`](https://tc39.es/ecma262/#sec-array.prototype.join), [`keys`](https://tc39.es/ecma262/#sec-array.prototype.keys), [`map`](https://tc39.es/ecma262/#sec-array.prototype.map), [`reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`some`](https://tc39.es/ecma262/#sec-array.prototype.some), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
|
|
30
|
+
To convert `Observable` to `AsyncIterableIterator`, [use `ReadableStream` as intermediate format](#converting-an-observable-to-asynciterableiterator).
|
|
35
31
|
|
|
36
32
|
### Converting an iterator to iterable
|
|
37
33
|
|
|
38
|
-
`iteratorToIterable`
|
|
34
|
+
`iteratorToIterable` and `asyncIteratorToAsyncIterable` enable a [pure iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator) to be iterable using a for-loop statement.
|
|
39
35
|
|
|
40
36
|
```ts
|
|
41
37
|
const iterate = (): Iterator<number> => {
|
|
@@ -44,10 +40,10 @@ const iterate = (): Iterator<number> => {
|
|
|
44
40
|
return {
|
|
45
41
|
next: () => {
|
|
46
42
|
if (++value <= 3) {
|
|
47
|
-
return {
|
|
43
|
+
return { value };
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
return { done: true, value: undefined }
|
|
46
|
+
return { done: true, value: undefined } satisfies IteratorResult<number>;
|
|
51
47
|
}
|
|
52
48
|
};
|
|
53
49
|
};
|
|
@@ -57,29 +53,31 @@ for (const value of iteratorToIterable(iterate())) {
|
|
|
57
53
|
}
|
|
58
54
|
```
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
`Observable` and `Symbol.observable` is re-exported from `core-js-pure` with proper type definitions.
|
|
56
|
+
Note: calling `[Symbol.iterator]()` or `[Symbol.asyncIterator]()` will not restart the iteration. This is because iterator is an instance of iteration and is not restartable.
|
|
63
57
|
|
|
64
58
|
### Converting an `Observable` to `AsyncIterableIterator`
|
|
65
59
|
|
|
66
|
-
`
|
|
60
|
+
`ReadableStream` can be used as an intermediate format when converting an `Observable` to `AsyncIterableIterator`.
|
|
67
61
|
|
|
68
|
-
`Observable` is push-based and
|
|
62
|
+
Note: `Observable` is push-based and it does not support flow control. When converting to `AsyncIterableIteratorrr`, the internal buffer of `ReadableStream` could build up quickly.
|
|
69
63
|
|
|
70
64
|
```ts
|
|
71
65
|
const observable = Observable.from([1, 2, 3]);
|
|
66
|
+
const readable = observableSubscribeAsReadable(observable);
|
|
67
|
+
const iterable = readerValues(readable.getReader());
|
|
72
68
|
|
|
73
|
-
for await (const value of
|
|
69
|
+
for await (const value of iterable) {
|
|
74
70
|
console.log(value); // Prints "1", "2", "3".
|
|
75
71
|
}
|
|
76
72
|
```
|
|
77
73
|
|
|
74
|
+
Note: calling `[Symbol.asyncIterator]()` will not resubscribe and read from the start of the observable. This is because the intermediate format does not support restart.
|
|
75
|
+
|
|
78
76
|
### Converting an `AsyncIterable` to `Observable`
|
|
79
77
|
|
|
80
78
|
`Observable.from` converts `Iterable` into `Observable`. However, it does not convert `AsyncIterable`.
|
|
81
79
|
|
|
82
|
-
`observableFromAsync` will convert `AsyncIterable` into `Observable`.
|
|
80
|
+
`observableFromAsync` will convert `AsyncIterable` into `Observable`. It will try to restart the iteration by calling `[Symbol.asyncIterator]()`.
|
|
83
81
|
|
|
84
82
|
```ts
|
|
85
83
|
async function* generate() {
|
|
@@ -94,14 +92,81 @@ const next = value => console.log(value);
|
|
|
94
92
|
observable.subscribe({ next }); // Prints "1", "2", "3".
|
|
95
93
|
```
|
|
96
94
|
|
|
95
|
+
Note: `observableFromAsync` will call `[Symbol.asyncIterator]()` initially to restart the iteration where possible.
|
|
96
|
+
|
|
97
|
+
Note: It is not recommended to convert `AsyncGenerator` to an `Observable`. `AsyncGenerator` has more functionalities and `Observable` does not support many of them.
|
|
98
|
+
|
|
99
|
+
### Converting an `Observable` to `ReadableStream`
|
|
100
|
+
|
|
101
|
+
`ReadableStream` is powerful for transforming and piping stream of data. It can be formed using data from both push-based and pull-based source with backpressuree.
|
|
102
|
+
|
|
103
|
+
Note: `Observable` is push-based and it does not support flow control. When converting to `ReadableStream`, the internal buffer could build up quickly.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const observable = Observable.from([1, 2, 3]);
|
|
107
|
+
const readable = observableSubscribeAsReadable(observable);
|
|
108
|
+
|
|
109
|
+
readable.pipeTo(stream.writable); // Will write 1, 2, 3.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Converting a `ReadableStreamDefaultReader` to `AsyncIterableIterator`
|
|
113
|
+
|
|
114
|
+
`readerValues` will convert default reader of `ReadableStream` into an `AsyncIterableIterator` to use in for-loop.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const readableStream = new ReadableStream({
|
|
118
|
+
start(controller) {
|
|
119
|
+
controller.enqueue(1);
|
|
120
|
+
controller.enqueue(2);
|
|
121
|
+
},
|
|
122
|
+
pull(controller) {
|
|
123
|
+
controller.enqueue(3);
|
|
124
|
+
controller.close();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const iterable = readerValues(readableStream.getReader());
|
|
129
|
+
|
|
130
|
+
for await (const value of iterable) {
|
|
131
|
+
console.log(value); // Prints "1", "2", "3".
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Note: `[Symbol.asyncIterator]()` will not restart the reader and read from start of the stream. Reader is not restartable and streams are not seekable.
|
|
136
|
+
|
|
137
|
+
### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
|
|
138
|
+
|
|
139
|
+
> Notes: this feature is part of [Streams Standard](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static).
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const iterable = [1, 2, 3].values();
|
|
143
|
+
const readable = readableStreamFrom(iterable);
|
|
144
|
+
|
|
145
|
+
readable.pipeTo(stream.writable); // Will write 1, 2, 3.
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Note: `readableStreamFrom()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
|
|
149
|
+
|
|
150
|
+
## Others
|
|
151
|
+
|
|
152
|
+
### Typed `Observable`
|
|
153
|
+
|
|
154
|
+
`Observable` and `Symbol.observable` is re-exported from `core-js-pure` with proper type definitions.
|
|
155
|
+
|
|
97
156
|
### Producer-consumer queue
|
|
98
157
|
|
|
99
|
-
`
|
|
158
|
+
`IterableWritableStream` is a push-based producer-consumer queue designed to decouple the flow between a producer and multiple consumers. The producer can push a new job at anytime. The consumer can pull a job at its own convenience via for-loop.
|
|
159
|
+
|
|
160
|
+
`IterableWritableStream` supports multiple consumers and continuation:
|
|
100
161
|
|
|
101
|
-
|
|
162
|
+
- Multiple consumers: when 2 or more consumers are active at the same time, jobs will be distributed across all consumers in a round robin fashion when possible
|
|
163
|
+
- Continuation: when the last consumer disconnected while producer keep pushing new jobs, the next consumer will pick up where the last consumer left
|
|
164
|
+
|
|
165
|
+
Compare to pull-based queue, a push-based queue is easy to use. However, pull-based queue offers better flow control as it will produce a job only if there is a consumer ready to consume.
|
|
102
166
|
|
|
103
167
|
```ts
|
|
104
|
-
const iterable = new
|
|
168
|
+
const iterable = new IterableWritableStream();
|
|
169
|
+
const writer = iterable.getWriter();
|
|
105
170
|
|
|
106
171
|
(async function consumer() {
|
|
107
172
|
for await (const value of iterable) {
|
|
@@ -112,45 +177,87 @@ const iterable = new PushAsyncIterableIterator();
|
|
|
112
177
|
})();
|
|
113
178
|
|
|
114
179
|
(async function producer() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
180
|
+
writer.write(1);
|
|
181
|
+
writer.write(2);
|
|
182
|
+
writer.write(3);
|
|
183
|
+
writer.close();
|
|
119
184
|
})();
|
|
120
185
|
|
|
121
186
|
// Prints "1", "2", "3", "Done".
|
|
122
187
|
```
|
|
123
188
|
|
|
124
|
-
###
|
|
189
|
+
### Using for-loop with generator
|
|
190
|
+
|
|
191
|
+
Compare to `Iterator`, `Generator` offers advanced capability.
|
|
125
192
|
|
|
126
|
-
|
|
193
|
+
When using for-loop with generator, the last value return from the generator is lost.
|
|
194
|
+
|
|
195
|
+
The `generatorWithLastValue()` and `asyncGeneratorWithLastValue()` helps bridge the for-loop usage by capturing the value returned as `{ done: true }` and make it accessible via `lastValue()`.
|
|
127
196
|
|
|
128
197
|
```ts
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
});
|
|
198
|
+
const generator = generatorWithLastValue(
|
|
199
|
+
(function* () {
|
|
200
|
+
yield 1; // { done: false, value: 1 }
|
|
201
|
+
yield 2; // { done: false, value: 2 }
|
|
202
|
+
yield 3; // { done: false, value: 3 }
|
|
136
203
|
|
|
137
|
-
|
|
204
|
+
return 'end'; // { done: true, value: 'end' }
|
|
205
|
+
})()
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
for (const value of generator) {
|
|
138
209
|
console.log(value); // Prints "1", "2", "3".
|
|
139
210
|
}
|
|
211
|
+
|
|
212
|
+
console.log(generator.lastValue()); // Prints "end".
|
|
140
213
|
```
|
|
141
214
|
|
|
142
|
-
|
|
215
|
+
Note: `lastValue()` will throw if it is being called before end of iteration. Also, excessive calls to `next()` will return `{ done: true, value: undefined }`, thus, `lastValue()` could become `undefined` if `next()` is called after the end of iteration.
|
|
143
216
|
|
|
144
|
-
`
|
|
217
|
+
The value returned from `generatorWithLastValue()`/`asyncGeneratorWithLastValue()` will passthrough all function calls to original `Generator` with a minor difference. Calling `[Symbol.iterator]()`/`[Symbol.asyncIterator]()` on the returned generator will not start a fresh iteration. If a fresh iteration is required, create a new one before passing it to `generatorWithLastValue()`/`asyncGeneratorWithLastValue()`.
|
|
145
218
|
|
|
146
219
|
```ts
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
220
|
+
const generator = generatorWithLastValue(
|
|
221
|
+
(function* () {
|
|
222
|
+
// ...
|
|
223
|
+
})()[Symbol.iterator]() // Creates a fresh iteration.
|
|
224
|
+
);
|
|
225
|
+
```
|
|
150
226
|
|
|
151
|
-
|
|
227
|
+
## Adding types to `core-js-pure`
|
|
228
|
+
|
|
229
|
+
We added types to implementation from `core-js-pure`:
|
|
230
|
+
|
|
231
|
+
- [`Iterator.drop`](https://tc39.es/ecma262/#sec-array.prototype.drop)
|
|
232
|
+
- [`Iterator.every`](https://tc39.es/ecma262/#sec-array.prototype.every)
|
|
233
|
+
- [`Iterator.filter`](https://tc39.es/ecma262/#sec-array.prototype.filter)
|
|
234
|
+
- [`Iterator.find`](https://tc39.es/ecma262/#sec-array.prototype.find)
|
|
235
|
+
- [`Iterator.flatMap`](https://tc39.es/ecma262/#sec-array.prototype.flatmap)
|
|
236
|
+
- [`Iterator.forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach)
|
|
237
|
+
- [`Iterator.from`](https://tc39.es/ecma262/#sec-array.prototype.from)
|
|
238
|
+
- [`Iterator.map`](https://tc39.es/ecma262/#sec-array.prototype.map)
|
|
239
|
+
- [`Iterator.reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce)
|
|
240
|
+
- [`Iterator.some`](https://tc39.es/ecma262/#sec-array.prototype.some)
|
|
241
|
+
- [`Iterator.take`](https://tc39.es/ecma262/#sec-array.prototype.take)
|
|
242
|
+
- [`Iterator.toArray`](https://tc39.es/ecma262/#sec-array.prototype.toarray)
|
|
243
|
+
|
|
244
|
+
## `Array.prototype` ports
|
|
245
|
+
|
|
246
|
+
We ported majority of functions from `Array.prototype.*` to `iterator*`.
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
import { iteratorIncludes, iteratorReduce } from 'iter-fest'; // Via default exports.
|
|
250
|
+
import { iteratorSome } from 'iter-fest/iteratorSome'; // Via named exports.
|
|
251
|
+
|
|
252
|
+
const iterator: iterator<number> = [1, 2, 3, 4, 5].values();
|
|
253
|
+
|
|
254
|
+
console.log(iteratorIncludes(iterator, 3)); // Prints "true".
|
|
255
|
+
console.log(iteratorReduce(iterator, (sum, value) => sum + value, 0)); // Prints "15".
|
|
256
|
+
console.log(iteratorSome(iterator, value => value % 2)); // Prints "true".
|
|
152
257
|
```
|
|
153
258
|
|
|
259
|
+
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`findIndex`](https://tc39.es/ecma262/#sec-array.prototype.findindex), [`findLast`](https://tc39.es/ecma262/#sec-array.prototype.findlast), [`findLastIndex`](https://tc39.es/ecma262/#sec-array.prototype.findlastindex), [`includes`](https://tc39.es/ecma262/#sec-array.prototype.includes), [`indexOf`](https://tc39.es/ecma262/#sec-array.prototype.indexof), [`join`](https://tc39.es/ecma262/#sec-array.prototype.join), [`keys`](https://tc39.es/ecma262/#sec-array.prototype.keys), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
|
|
260
|
+
|
|
154
261
|
## Behaviors
|
|
155
262
|
|
|
156
263
|
### How this compares to the TC39 proposals?
|
|
@@ -166,27 +273,27 @@ Majority of functions should work the same way with same complexity and performa
|
|
|
166
273
|
There are minor differences on some functions:
|
|
167
274
|
|
|
168
275
|
- `findLast` and `findLastIndex`
|
|
169
|
-
- Instead of iterating from the right side,
|
|
170
|
-
- Thus, with an
|
|
276
|
+
- Instead of iterating from the right side, iterators must start from left side
|
|
277
|
+
- Thus, with an iterator of 5 items, `predicate` will be called exactly 5 times with `O(N)` complexity
|
|
171
278
|
- In contrast, its counterpart in `Array` will be called between 1 and 5 times with `O(log N)` complexity
|
|
172
279
|
- `at`, `includes`, `indexOf`, `slice`, and `toSpliced`
|
|
173
280
|
- Index arguments cannot be negative finite number
|
|
174
|
-
- Negative finite number means traversing from right side, which an iterator
|
|
281
|
+
- Negative finite number means traversing from right side, which an iterator may not have an end
|
|
175
282
|
- Infinites, zeroes, and positive numbers are supported
|
|
176
283
|
|
|
177
284
|
### Why `Array.prototype.push` is not ported?
|
|
178
285
|
|
|
179
|
-
Some functions that modify the array are not ported, such as, `copyWithin`, `fill`, `pop`, `push`, `reverse`, `shift`, `splice`, `unshift`, etc.
|
|
286
|
+
Some functions that modify the array are not ported, such as, `copyWithin`, `fill`, `pop`, `push`, `reverse`, `shift`, `splice`, `unshift`, etc. Iterators are read-only and we prefer to keep it that way.
|
|
180
287
|
|
|
181
|
-
Some functions that do not have actual functionality in the
|
|
288
|
+
Some functions that do not have actual functionality in the iterator world are not ported, such as, `values`, etc.
|
|
182
289
|
|
|
183
290
|
Some functions that cannot not retains their complexity or performance characteristics are not ported. These functions usually iterate from the other end or requires random access, such as, `lastIndexOf`, `reduceRight`, `sort`, `toReversed`, `toSorted`, etc.
|
|
184
291
|
|
|
185
292
|
If you think a specific function should be ported, please submit a pull request to us.
|
|
186
293
|
|
|
187
|
-
### How about asynchronous
|
|
294
|
+
### How about asynchronous iterators?
|
|
188
295
|
|
|
189
|
-
Yes, this is on our roadmap. This will enable traverse
|
|
296
|
+
Yes, this is on our roadmap. This will enable traverse iterators [across domains/workers via `MessagePort`](https://npmjs.com/package/message-port-rpc). We welcome pull requests.
|
|
190
297
|
|
|
191
298
|
### How about functions outside of `Array.prototype`?
|
|
192
299
|
|
|
@@ -199,18 +306,21 @@ Generator has more functionalities than iterator and array. It is not recommende
|
|
|
199
306
|
- Generator can define the return value
|
|
200
307
|
- `return { done: true, value: 'the very last value' }`
|
|
201
308
|
- Iterating generator using for-loop will not get any values from `{ done: true }`
|
|
309
|
+
- The `generatorWithLastValue()` will help capturing and retrieving the last return value
|
|
202
310
|
- Generator can receive feedback values from its iterator
|
|
203
311
|
- `generator.next('something')`, the feedback can be assigned to variable via `const feedback = yield;`
|
|
204
312
|
- For-loop cannot send feedbacks to generator
|
|
205
313
|
|
|
206
314
|
### When should I use `Iterable`, `IterableIterator` and `Iterator`?
|
|
207
315
|
|
|
208
|
-
For best compatibility, you should generally follow this API signature: use `Iterable` for inputs, and use `IterableIterator` for outputs. You should avoid exporting pure `Iterator`.
|
|
316
|
+
For best compatibility, you should generally follow this API signature: use `Iterable` for inputs, and use `IterableIterator` for outputs. You should avoid exporting pure `Iterator`. Sample function signature should looks below.
|
|
209
317
|
|
|
210
318
|
```ts
|
|
211
|
-
function
|
|
319
|
+
function myFunction<T>(input: Iterable<T>): IterableIterator<T>;
|
|
212
320
|
```
|
|
213
321
|
|
|
322
|
+
`IterableIterator` may opt to support restarting the iteration through `[Symbol.iterator]()`. When consuming an `IterableIterator`, you should call `[Symbol.iterator]()` to obtain a fresh iteration or use for-loop statement if possible. However, `[Symbol.iterator]()` is an opt-in feature and does not always guarantee a fresh iteration.
|
|
323
|
+
|
|
214
324
|
### What is on the roadmap?
|
|
215
325
|
|
|
216
326
|
We are planning to bring iterables and its siblings together, including:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/generatorWithLastValue.ts
|
|
2
|
+
var STILL_ITERATING = Symbol();
|
|
3
|
+
function generatorWithLastValue(generator) {
|
|
4
|
+
let lastValue = STILL_ITERATING;
|
|
5
|
+
const generatorWithLastValue2 = {
|
|
6
|
+
[Symbol.iterator]() {
|
|
7
|
+
return generatorWithLastValue2;
|
|
8
|
+
},
|
|
9
|
+
lastValue() {
|
|
10
|
+
if (lastValue === STILL_ITERATING) {
|
|
11
|
+
throw new Error("Iteration has not complete yet, cannot get last value.");
|
|
12
|
+
}
|
|
13
|
+
return lastValue;
|
|
14
|
+
},
|
|
15
|
+
next(next) {
|
|
16
|
+
const result = generator.next(next);
|
|
17
|
+
if (result.done) {
|
|
18
|
+
lastValue = result.value;
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
},
|
|
22
|
+
return(value) {
|
|
23
|
+
return generator.return(value);
|
|
24
|
+
},
|
|
25
|
+
throw(error) {
|
|
26
|
+
return generator.throw(error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return generatorWithLastValue2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
generatorWithLastValue
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-2DE3J4J7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generatorWithLastValue.ts"],"sourcesContent":["const STILL_ITERATING = Symbol();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type GeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = Generator<T, TReturn, TNext> & {\n lastValue(): TReturn;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generatorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(\n generator: Generator<T, TReturn, TNext>\n): GeneratorWithLastValue<T, TReturn, TNext> {\n let lastValue: typeof STILL_ITERATING | TReturn = STILL_ITERATING;\n\n const generatorWithLastValue = {\n [Symbol.iterator]() {\n return generatorWithLastValue;\n },\n lastValue(): TReturn {\n if (lastValue === STILL_ITERATING) {\n throw new Error('Iteration has not complete yet, cannot get last value.');\n }\n\n return lastValue;\n },\n next(next: TNext) {\n const result = generator.next(next);\n\n if (result.done) {\n lastValue = result.value;\n }\n\n return result;\n },\n return(value: TReturn) {\n return generator.return(value);\n },\n throw(error: unknown) {\n return generator.throw(error);\n }\n };\n\n return generatorWithLastValue;\n}\n"],"mappings":";AAAA,IAAM,kBAAkB,OAAO;AAQxB,SAAS,uBACd,WAC2C;AAC3C,MAAI,YAA8C;AAElD,QAAMA,0BAAyB;AAAA,IAC7B,CAAC,OAAO,QAAQ,IAAI;AAClB,aAAOA;AAAA,IACT;AAAA,IACA,YAAqB;AACnB,UAAI,cAAc,iBAAiB;AACjC,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,IACA,KAAK,MAAa;AAChB,YAAM,SAAS,UAAU,KAAK,IAAI;AAElC,UAAI,OAAO,MAAM;AACf,oBAAY,OAAO;AAAA,MACrB;AAEA,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAgB;AACrB,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B;AAAA,IACA,MAAM,OAAgB;AACpB,aAAO,UAAU,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAEA,SAAOA;AACT;","names":["generatorWithLastValue"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorSome.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport some from 'core-js-pure/full/iterator/some';\n\n/**\n * Determines whether the specified callback function returns true for any element of an iterable.\n *\n * @param predicate A function that accepts up to three arguments. The some method calls the predicate function for each element in the iterable until the predicate returns a value which is coercible to the Boolean value true, or until the end of the iterable.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorSome<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => unknown): boolean {\n return some(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,UAAU;AASV,SAAS,aAAgB,UAAuB,WAA0D;AAC/G,SAAO,KAAK,UAAU,SAAS;AACjC;","names":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toIntegerOrInfinity
|
|
3
3
|
} from "./chunk-W5NEOEVE.mjs";
|
|
4
|
+
import {
|
|
5
|
+
iteratorToIterable
|
|
6
|
+
} from "./chunk-MNDAEMYM.mjs";
|
|
4
7
|
|
|
5
|
-
// src/
|
|
6
|
-
function
|
|
8
|
+
// src/iteratorIndexOf.ts
|
|
9
|
+
function iteratorIndexOf(iterator, searchElement, fromIndex = 0) {
|
|
7
10
|
let index = 0;
|
|
8
11
|
fromIndex = toIntegerOrInfinity(fromIndex);
|
|
9
12
|
if (fromIndex !== Infinity) {
|
|
@@ -11,7 +14,7 @@ function iterableIndexOf(iterable, searchElement, fromIndex = 0) {
|
|
|
11
14
|
if (fromIndex < 0) {
|
|
12
15
|
throw new TypeError("fromIndex cannot be a negative finite number");
|
|
13
16
|
}
|
|
14
|
-
for (const item of
|
|
17
|
+
for (const item of iteratorToIterable(iterator)) {
|
|
15
18
|
if (index >= fromIndex && Object.is(item, searchElement)) {
|
|
16
19
|
return index;
|
|
17
20
|
}
|
|
@@ -22,6 +25,6 @@ function iterableIndexOf(iterable, searchElement, fromIndex = 0) {
|
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export {
|
|
25
|
-
|
|
28
|
+
iteratorIndexOf
|
|
26
29
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-AN54W42O.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorIndexOf.ts"],"sourcesContent":["import { iteratorToIterable } from './iteratorToIterable';\nimport toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns the index of the first occurrence of a value in an iterator, or -1 if it is not present.\n *\n * @param searchElement The value to locate in the iterator.\n * @param fromIndex The iterator index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\nexport function iteratorIndexOf<T>(iterator: Iterator<T>, searchElement: T, fromIndex: number = 0): number {\n let index = 0;\n\n fromIndex = toIntegerOrInfinity(fromIndex);\n\n if (fromIndex !== Infinity) {\n fromIndex = fromIndex === -Infinity ? 0 : fromIndex;\n\n if (fromIndex < 0) {\n // TODO: Support negative fromIndex.\n throw new TypeError('fromIndex cannot be a negative finite number');\n }\n\n for (const item of iteratorToIterable(iterator)) {\n if (index >= fromIndex && Object.is(item, searchElement)) {\n return index;\n }\n\n index++;\n }\n }\n\n return -1;\n}\n"],"mappings":";;;;;;;;AASO,SAAS,gBAAmB,UAAuB,eAAkB,YAAoB,GAAW;AACzG,MAAI,QAAQ;AAEZ,cAAY,oBAAoB,SAAS;AAEzC,MAAI,cAAc,UAAU;AAC1B,gBAAY,cAAc,YAAY,IAAI;AAE1C,QAAI,YAAY,GAAG;AAEjB,YAAM,IAAI,UAAU,8CAA8C;AAAA,IACpE;AAEA,eAAW,QAAQ,mBAAmB,QAAQ,GAAG;AAC/C,UAAI,SAAS,aAAa,OAAO,GAAG,MAAM,aAAa,GAAG;AACxD,eAAO;AAAA,MACT;AAEA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/asyncGeneratorWithLastValue.ts
|
|
2
|
+
var STILL_ITERATING = Symbol();
|
|
3
|
+
function asyncGeneratorWithLastValue(generator) {
|
|
4
|
+
let lastValue = STILL_ITERATING;
|
|
5
|
+
const asyncGeneratorWithLastValue2 = {
|
|
6
|
+
[Symbol.asyncIterator]() {
|
|
7
|
+
return asyncGeneratorWithLastValue2;
|
|
8
|
+
},
|
|
9
|
+
lastValue() {
|
|
10
|
+
if (lastValue === STILL_ITERATING) {
|
|
11
|
+
throw new Error("Iteration has not complete yet, cannot get last value.");
|
|
12
|
+
}
|
|
13
|
+
return lastValue;
|
|
14
|
+
},
|
|
15
|
+
async next(next) {
|
|
16
|
+
const result = await generator.next(next);
|
|
17
|
+
if (result.done) {
|
|
18
|
+
lastValue = result.value;
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
},
|
|
22
|
+
return(value) {
|
|
23
|
+
return generator.return(value);
|
|
24
|
+
},
|
|
25
|
+
throw(error) {
|
|
26
|
+
return generator.throw(error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return asyncGeneratorWithLastValue2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
asyncGeneratorWithLastValue
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-ANRVAYLW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asyncGeneratorWithLastValue.ts"],"sourcesContent":["const STILL_ITERATING = Symbol();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AsyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = AsyncGenerator<\n T,\n TReturn,\n TNext\n> & {\n lastValue(): TReturn;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function asyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(\n generator: AsyncGenerator<T, TReturn, TNext>\n): AsyncGeneratorWithLastValue<T, TReturn, TNext> {\n let lastValue: typeof STILL_ITERATING | TReturn = STILL_ITERATING;\n\n const asyncGeneratorWithLastValue = {\n [Symbol.asyncIterator]() {\n return asyncGeneratorWithLastValue;\n },\n lastValue(): TReturn {\n if (lastValue === STILL_ITERATING) {\n throw new Error('Iteration has not complete yet, cannot get last value.');\n }\n\n return lastValue;\n },\n async next(next: TNext) {\n const result = await generator.next(next);\n\n if (result.done) {\n lastValue = result.value;\n }\n\n return result;\n },\n return(value: TReturn) {\n return generator.return(value);\n },\n throw(error: unknown) {\n return generator.throw(error);\n }\n };\n\n return asyncGeneratorWithLastValue;\n}\n"],"mappings":";AAAA,IAAM,kBAAkB,OAAO;AAYxB,SAAS,4BACd,WACgD;AAChD,MAAI,YAA8C;AAElD,QAAMA,+BAA8B;AAAA,IAClC,CAAC,OAAO,aAAa,IAAI;AACvB,aAAOA;AAAA,IACT;AAAA,IACA,YAAqB;AACnB,UAAI,cAAc,iBAAiB;AACjC,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,KAAK,MAAa;AACtB,YAAM,SAAS,MAAM,UAAU,KAAK,IAAI;AAExC,UAAI,OAAO,MAAM;AACf,oBAAY,OAAO;AAAA,MACrB;AAEA,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAgB;AACrB,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B;AAAA,IACA,MAAM,OAAgB;AACpB,aAAO,UAAU,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAEA,SAAOA;AACT;","names":["asyncGeneratorWithLastValue"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iteratorToIterable
|
|
3
|
+
} from "./chunk-MNDAEMYM.mjs";
|
|
4
|
+
|
|
5
|
+
// src/iteratorEntries.ts
|
|
6
|
+
function* iteratorEntries(iterator) {
|
|
7
|
+
let index = 0;
|
|
8
|
+
for (const value of iteratorToIterable(iterator)) {
|
|
9
|
+
yield [index++, value];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
iteratorEntries
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-BSAPKNNZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorEntries.ts"],"sourcesContent":["import { iteratorToIterable } from './iteratorToIterable';\n\n/**\n * Returns an iterator of key, value pairs for every entry in the iterator\n */\nexport function* iteratorEntries<T>(iterator: Iterator<T>): IterableIterator<[number, T]> {\n let index = 0;\n\n for (const value of iteratorToIterable(iterator)) {\n yield [index++, value];\n }\n}\n"],"mappings":";;;;;AAKO,UAAU,gBAAmB,UAAsD;AACxF,MAAI,QAAQ;AAEZ,aAAW,SAAS,mBAAmB,QAAQ,GAAG;AAChD,UAAM,CAAC,SAAS,KAAK;AAAA,EACvB;AACF;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/private/withResolvers.ts
|
|
2
|
+
import coreJSPromiseWithResolvers from "core-js-pure/full/promise/with-resolvers";
|
|
3
|
+
function withResolvers() {
|
|
4
|
+
return coreJSPromiseWithResolvers();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/iterableWritableStream.ts
|
|
8
|
+
var CLOSE = Symbol();
|
|
9
|
+
var IterableWritableStream = class extends WritableStream {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
close: () => {
|
|
13
|
+
this.#buffer.push(CLOSE);
|
|
14
|
+
this.#writeResolvers.resolve();
|
|
15
|
+
},
|
|
16
|
+
write: (chunk) => {
|
|
17
|
+
this.#buffer.push(chunk);
|
|
18
|
+
this.#writeResolvers.resolve();
|
|
19
|
+
this.#writeResolvers = withResolvers();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
#buffer = [];
|
|
24
|
+
#writeResolvers = withResolvers();
|
|
25
|
+
[Symbol.asyncIterator]() {
|
|
26
|
+
return {
|
|
27
|
+
next: async () => {
|
|
28
|
+
while (!this.#buffer.length) {
|
|
29
|
+
await this.#writeResolvers.promise;
|
|
30
|
+
}
|
|
31
|
+
const value = this.#buffer[0];
|
|
32
|
+
if (value === CLOSE) {
|
|
33
|
+
return { done: true, value: void 0 };
|
|
34
|
+
}
|
|
35
|
+
this.#buffer.shift();
|
|
36
|
+
await void 0;
|
|
37
|
+
return { done: false, value };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
IterableWritableStream
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=chunk-BWMXKULC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/private/withResolvers.ts","../src/iterableWritableStream.ts"],"sourcesContent":["// @ts-expect-error \"core-js\" is not typed.\nimport coreJSPromiseWithResolvers from 'core-js-pure/full/promise/with-resolvers';\n\nexport default function withResolvers<T>(): PromiseWithResolvers<T> {\n return coreJSPromiseWithResolvers();\n}\n","import withResolvers from './private/withResolvers';\n\nconst CLOSE = Symbol();\n\nexport class IterableWritableStream<T> extends WritableStream<T> {\n constructor() {\n super({\n close: () => {\n this.#buffer.push(CLOSE);\n this.#writeResolvers.resolve();\n },\n write: (chunk: T) => {\n this.#buffer.push(chunk);\n this.#writeResolvers.resolve();\n this.#writeResolvers = withResolvers();\n }\n });\n }\n\n #buffer: (T | typeof CLOSE)[] = [];\n #writeResolvers: PromiseWithResolvers<void> = withResolvers();\n\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return {\n next: async () => {\n while (!this.#buffer.length) {\n await this.#writeResolvers.promise;\n }\n\n const value = this.#buffer[0] as T | typeof CLOSE;\n\n if (value === CLOSE) {\n return { done: true, value: undefined };\n }\n\n // If it is not CLOSE, remove it from the queue.\n this.#buffer.shift();\n\n // Idle here so concurrent iteration has a chance to pick up the next value in a round robin fashion.\n await undefined;\n\n return { done: false, value };\n }\n };\n }\n}\n"],"mappings":";AACA,OAAO,gCAAgC;AAExB,SAAR,gBAA6D;AAClE,SAAO,2BAA2B;AACpC;;;ACHA,IAAM,QAAQ,OAAO;AAEd,IAAM,yBAAN,cAAwC,eAAkB;AAAA,EAC/D,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO,MAAM;AACX,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC,UAAa;AACnB,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAC7B,aAAK,kBAAkB,cAAc;AAAA,MACvC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,UAAgC,CAAC;AAAA,EACjC,kBAA8C,cAAc;AAAA,EAE5D,CAAC,OAAO,aAAa,IAAsB;AACzC,WAAO;AAAA,MACL,MAAM,YAAY;AAChB,eAAO,CAAC,KAAK,QAAQ,QAAQ;AAC3B,gBAAM,KAAK,gBAAgB;AAAA,QAC7B;AAEA,cAAM,QAAQ,KAAK,QAAQ,CAAC;AAE5B,YAAI,UAAU,OAAO;AACnB,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAGA,aAAK,QAAQ,MAAM;AAGnB,cAAM;AAEN,eAAO,EAAE,MAAM,OAAO,MAAM;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iteratorToIterable
|
|
3
|
+
} from "./chunk-MNDAEMYM.mjs";
|
|
4
|
+
|
|
5
|
+
// src/iteratorKeys.ts
|
|
6
|
+
function* iteratorKeys(iterator) {
|
|
7
|
+
let index = 0;
|
|
8
|
+
for (const _ of iteratorToIterable(iterator)) {
|
|
9
|
+
yield index++;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
iteratorKeys
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-CNCNQPK3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorKeys.ts"],"sourcesContent":["import { iteratorToIterable } from './iteratorToIterable';\n\n/**\n * Returns an iterator of keys in the iterator\n */\nexport function* iteratorKeys<T>(iterator: Iterator<T>): IterableIterator<number> {\n let index = 0;\n\n for (const _ of iteratorToIterable(iterator)) {\n yield index++;\n }\n}\n"],"mappings":";;;;;AAKO,UAAU,aAAgB,UAAiD;AAChF,MAAI,QAAQ;AAEZ,aAAW,KAAK,mBAAmB,QAAQ,GAAG;AAC5C,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toIntegerOrInfinity
|
|
3
3
|
} from "./chunk-W5NEOEVE.mjs";
|
|
4
|
+
import {
|
|
5
|
+
iteratorToIterable
|
|
6
|
+
} from "./chunk-MNDAEMYM.mjs";
|
|
4
7
|
|
|
5
|
-
// src/
|
|
6
|
-
function*
|
|
8
|
+
// src/iteratorSlice.ts
|
|
9
|
+
function* iteratorSlice(iterator, start = 0, end = Infinity) {
|
|
7
10
|
let index = 0;
|
|
8
11
|
start = toIntegerOrInfinity(start);
|
|
9
12
|
start = start === -Infinity ? 0 : start;
|
|
@@ -18,7 +21,7 @@ function* iterableSlice(iterable, start = 0, end = Infinity) {
|
|
|
18
21
|
if (start === Infinity) {
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
|
-
for (const item of
|
|
24
|
+
for (const item of iteratorToIterable(iterator)) {
|
|
22
25
|
if (index >= start && index < end) {
|
|
23
26
|
yield item;
|
|
24
27
|
}
|
|
@@ -30,6 +33,6 @@ function* iterableSlice(iterable, start = 0, end = Infinity) {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export {
|
|
33
|
-
|
|
36
|
+
iteratorSlice
|
|
34
37
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-EQZQP6GW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorSlice.ts"],"sourcesContent":["import { iteratorToIterable } from './iteratorToIterable';\nimport toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns a copy of a section of an iterator.\n * For both start and end, a negative index can be used to indicate an offset from the end of the iterator.\n * For example, -2 refers to the second to last element of the iterator.\n *\n * @param start The beginning index of the specified portion of the iterator.\n * If start is undefined, then the slice begins at index 0.\n *\n * @param end The end index of the specified portion of the iterator. This is exclusive of the element at the index 'end'.\n * If end is undefined, then the slice extends to the end of the iterator.\n */\nexport function* iteratorSlice<T>(\n iterator: Iterator<T>,\n start: number = 0,\n end: number = Infinity\n): IterableIterator<T> {\n let index = 0;\n\n start = toIntegerOrInfinity(start);\n start = start === -Infinity ? 0 : start;\n end = toIntegerOrInfinity(end);\n end = end === -Infinity ? 0 : end;\n\n if (start < 0) {\n throw new TypeError('start cannot be a negative finite number');\n }\n\n if (end < 0) {\n throw new TypeError('end cannot be a negative finite number');\n }\n\n if (start === Infinity) {\n return;\n }\n\n for (const item of iteratorToIterable(iterator)) {\n if (index >= start && index < end) {\n yield item;\n }\n\n index++;\n\n if (index > end) {\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;AAcO,UAAU,cACf,UACA,QAAgB,GAChB,MAAc,UACO;AACrB,MAAI,QAAQ;AAEZ,UAAQ,oBAAoB,KAAK;AACjC,UAAQ,UAAU,YAAY,IAAI;AAClC,QAAM,oBAAoB,GAAG;AAC7B,QAAM,QAAQ,YAAY,IAAI;AAE9B,MAAI,QAAQ,GAAG;AACb,UAAM,IAAI,UAAU,0CAA0C;AAAA,EAChE;AAEA,MAAI,MAAM,GAAG;AACX,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AAEA,MAAI,UAAU,UAAU;AACtB;AAAA,EACF;AAEA,aAAW,QAAQ,mBAAmB,QAAQ,GAAG;AAC/C,QAAI,SAAS,SAAS,QAAQ,KAAK;AACjC,YAAM;AAAA,IACR;AAEA;AAEA,QAAI,QAAQ,KAAK;AACf;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|