iter-fest 0.1.1-main.9193c0a → 0.1.1-main.b1e260f
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 +267 -25
- 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-4RT2FROS.mjs +10 -0
- package/dist/chunk-4RT2FROS.mjs.map +1 -0
- package/dist/chunk-4ZBMXHD6.mjs +10 -0
- package/dist/chunk-4ZBMXHD6.mjs.map +1 -0
- package/dist/chunk-72AEHTPQ.mjs +38 -0
- package/dist/chunk-72AEHTPQ.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-AOZVPHE4.mjs +10 -0
- package/dist/chunk-AOZVPHE4.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-CNKIGQUS.mjs +10 -0
- package/dist/chunk-CNKIGQUS.mjs.map +1 -0
- package/dist/chunk-DC2ZV7KQ.mjs +10 -0
- package/dist/chunk-DC2ZV7KQ.mjs.map +1 -0
- package/dist/chunk-EIIP7YWB.mjs +27 -0
- package/dist/chunk-EIIP7YWB.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-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-FEOLYD5R.mjs +31 -0
- package/dist/chunk-FEOLYD5R.mjs.map +1 -0
- package/dist/chunk-FMIHIL6A.mjs +10 -0
- package/dist/chunk-FMIHIL6A.mjs.map +1 -0
- package/dist/chunk-GFJGWVES.mjs +10 -0
- package/dist/chunk-GFJGWVES.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-J3FQSENW.mjs +10 -0
- package/dist/chunk-J3FQSENW.mjs.map +1 -0
- package/dist/chunk-JVR6BUJA.mjs +10 -0
- package/dist/chunk-JVR6BUJA.mjs.map +1 -0
- package/dist/chunk-K4RCFPTZ.mjs +10 -0
- package/dist/chunk-K4RCFPTZ.mjs.map +1 -0
- package/dist/chunk-LB3MK3EU.mjs +10 -0
- package/dist/chunk-LB3MK3EU.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-NLXKATXE.mjs +10 -0
- package/dist/chunk-NLXKATXE.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-ODPKEUIR.mjs +10 -0
- package/dist/chunk-ODPKEUIR.mjs.map +1 -0
- package/dist/chunk-OJMT4K3R.mjs +8 -0
- package/dist/chunk-OJMT4K3R.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-QLVU73KN.mjs +10 -0
- package/dist/chunk-QLVU73KN.mjs.map +1 -0
- package/dist/chunk-R6SXIXMH.mjs +10 -0
- package/dist/chunk-R6SXIXMH.mjs.map +1 -0
- package/dist/chunk-RVIERPEV.mjs +26 -0
- package/dist/chunk-RVIERPEV.mjs.map +1 -0
- package/dist/chunk-S2LECQKY.mjs +10 -0
- package/dist/chunk-S2LECQKY.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-VIMGYUMQ.mjs +10 -0
- package/dist/chunk-VIMGYUMQ.mjs.map +1 -0
- package/dist/chunk-VLF6DI2U.mjs +30 -0
- package/dist/chunk-VLF6DI2U.mjs.map +1 -0
- package/dist/chunk-WUFMEPOM.mjs +10 -0
- package/dist/chunk-WUFMEPOM.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/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.asyncIteratorDrop.d.mts +12 -0
- package/dist/iter-fest.asyncIteratorDrop.d.ts +12 -0
- package/dist/iter-fest.asyncIteratorDrop.js +44 -0
- package/dist/iter-fest.asyncIteratorDrop.js.map +1 -0
- package/dist/iter-fest.asyncIteratorDrop.mjs +7 -0
- package/dist/iter-fest.asyncIteratorEvery.d.mts +25 -0
- package/dist/iter-fest.asyncIteratorEvery.d.ts +25 -0
- package/dist/iter-fest.asyncIteratorEvery.js +44 -0
- package/dist/iter-fest.asyncIteratorEvery.js.map +1 -0
- package/dist/iter-fest.asyncIteratorEvery.mjs +7 -0
- package/dist/iter-fest.asyncIteratorFilter.d.mts +18 -0
- package/dist/iter-fest.asyncIteratorFilter.d.ts +18 -0
- package/dist/iter-fest.asyncIteratorFilter.js +44 -0
- package/dist/iter-fest.asyncIteratorFilter.js.map +1 -0
- package/dist/iter-fest.asyncIteratorFilter.mjs +7 -0
- package/dist/iter-fest.asyncIteratorFind.d.mts +14 -0
- package/dist/iter-fest.asyncIteratorFind.d.ts +14 -0
- package/dist/iter-fest.asyncIteratorFind.js +44 -0
- package/dist/iter-fest.asyncIteratorFind.js.map +1 -0
- package/dist/iter-fest.asyncIteratorFind.mjs +7 -0
- package/dist/iter-fest.asyncIteratorFlatMap.d.mts +12 -0
- package/dist/iter-fest.asyncIteratorFlatMap.d.ts +12 -0
- package/dist/iter-fest.asyncIteratorFlatMap.js +44 -0
- package/dist/iter-fest.asyncIteratorFlatMap.js.map +1 -0
- package/dist/iter-fest.asyncIteratorFlatMap.mjs +7 -0
- package/dist/iter-fest.asyncIteratorForEach.d.mts +10 -0
- package/dist/iter-fest.asyncIteratorForEach.d.ts +10 -0
- package/dist/iter-fest.asyncIteratorForEach.js +44 -0
- package/dist/iter-fest.asyncIteratorForEach.js.map +1 -0
- package/dist/iter-fest.asyncIteratorForEach.mjs +7 -0
- package/dist/iter-fest.asyncIteratorFrom.d.mts +10 -0
- package/dist/iter-fest.asyncIteratorFrom.d.ts +10 -0
- package/dist/iter-fest.asyncIteratorFrom.js +44 -0
- package/dist/iter-fest.asyncIteratorFrom.js.map +1 -0
- package/dist/iter-fest.asyncIteratorFrom.mjs +7 -0
- package/dist/iter-fest.asyncIteratorMap.d.mts +10 -0
- package/dist/iter-fest.asyncIteratorMap.d.ts +10 -0
- package/dist/iter-fest.asyncIteratorMap.js +44 -0
- package/dist/iter-fest.asyncIteratorMap.js.map +1 -0
- package/dist/iter-fest.asyncIteratorMap.mjs +7 -0
- package/dist/iter-fest.asyncIteratorReduce.d.mts +23 -0
- package/dist/iter-fest.asyncIteratorReduce.d.ts +23 -0
- package/dist/iter-fest.asyncIteratorReduce.js +44 -0
- package/dist/iter-fest.asyncIteratorReduce.js.map +1 -0
- package/dist/iter-fest.asyncIteratorReduce.mjs +7 -0
- package/dist/iter-fest.asyncIteratorSome.d.mts +10 -0
- package/dist/iter-fest.asyncIteratorSome.d.ts +10 -0
- package/dist/iter-fest.asyncIteratorSome.js +44 -0
- package/dist/iter-fest.asyncIteratorSome.js.map +1 -0
- package/dist/iter-fest.asyncIteratorSome.mjs +7 -0
- package/dist/iter-fest.asyncIteratorTake.d.mts +12 -0
- package/dist/iter-fest.asyncIteratorTake.d.ts +12 -0
- package/dist/iter-fest.asyncIteratorTake.js +44 -0
- package/dist/iter-fest.asyncIteratorTake.js.map +1 -0
- package/dist/iter-fest.asyncIteratorTake.mjs +7 -0
- package/dist/iter-fest.asyncIteratorToArray.d.mts +10 -0
- package/dist/iter-fest.asyncIteratorToArray.d.ts +10 -0
- package/dist/iter-fest.asyncIteratorToArray.js +44 -0
- package/dist/iter-fest.asyncIteratorToArray.js.map +1 -0
- package/dist/iter-fest.asyncIteratorToArray.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 +50 -20
- package/dist/iter-fest.d.ts +50 -20
- 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.iterableWritableStream.js +82 -0
- package/dist/iter-fest.iterableWritableStream.js.map +1 -0
- package/dist/iter-fest.iterableWritableStream.mjs +7 -0
- package/dist/{iter-fest.iterableAt.d.ts → iter-fest.iteratorAt.d.mts} +2 -2
- package/dist/{iter-fest.iterableAt.d.mts → 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.iteratorEvery.mjs.map +1 -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.iteratorFilter.mjs.map +1 -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.iteratorFind.mjs.map +1 -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.iteratorFindIndex.mjs.map +1 -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.iteratorFindLast.mjs.map +1 -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.iteratorFindLastIndex.mjs.map +1 -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.iteratorFlatMap.mjs.map +1 -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.iteratorForEach.mjs.map +1 -0
- package/dist/iter-fest.iteratorFrom.d.mts +10 -0
- package/dist/iter-fest.iteratorFrom.d.ts +10 -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.iteratorFrom.mjs.map +1 -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.iteratorIncludes.mjs.map +1 -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.iteratorIndexOf.mjs.map +1 -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.iteratorJoin.mjs.map +1 -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.iteratorKeys.mjs.map +1 -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.iteratorMap.mjs.map +1 -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.iteratorReduce.mjs.map +1 -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 +10 -0
- package/dist/iter-fest.iteratorToArray.d.ts +10 -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.iteratorToAsync.d.mts +10 -0
- package/dist/iter-fest.iteratorToAsync.d.ts +10 -0
- package/dist/iter-fest.iteratorToAsync.js +44 -0
- package/dist/iter-fest.iteratorToAsync.js.map +1 -0
- package/dist/iter-fest.iteratorToAsync.mjs +7 -0
- package/dist/iter-fest.iteratorToAsync.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 +561 -179
- package/dist/iter-fest.js.map +1 -1
- package/dist/iter-fest.mjs +178 -62
- package/dist/iter-fest.observable.d.mts +51 -0
- package/dist/iter-fest.observable.d.ts +51 -0
- package/dist/iter-fest.observable.js +66 -0
- package/dist/iter-fest.observable.js.map +1 -0
- package/dist/iter-fest.observable.mjs +8 -0
- package/dist/iter-fest.observable.mjs.map +1 -0
- package/dist/iter-fest.observableFromAsync.d.mts +7 -0
- package/dist/iter-fest.observableFromAsync.d.ts +7 -0
- package/dist/iter-fest.observableFromAsync.js +91 -0
- package/dist/iter-fest.observableFromAsync.js.map +1 -0
- package/dist/iter-fest.observableFromAsync.mjs +9 -0
- package/dist/iter-fest.observableFromAsync.mjs.map +1 -0
- package/dist/iter-fest.observableSubscribeAsReadable.d.mts +7 -0
- package/dist/iter-fest.observableSubscribeAsReadable.d.ts +7 -0
- package/dist/iter-fest.observableSubscribeAsReadable.js +51 -0
- package/dist/iter-fest.observableSubscribeAsReadable.js.map +1 -0
- package/dist/iter-fest.observableSubscribeAsReadable.mjs +7 -0
- package/dist/iter-fest.observableSubscribeAsReadable.mjs.map +1 -0
- package/dist/iter-fest.observableValues.d.mts +7 -0
- package/dist/iter-fest.observableValues.d.ts +7 -0
- package/dist/iter-fest.observableValues.js +102 -0
- package/dist/iter-fest.observableValues.js.map +1 -0
- package/dist/iter-fest.observableValues.mjs +9 -0
- package/dist/iter-fest.observableValues.mjs.map +1 -0
- 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.readableStreamValues.d.mts +3 -0
- package/dist/iter-fest.readableStreamValues.d.ts +3 -0
- package/dist/{iter-fest.iterableEvery.js → iter-fest.readableStreamValues.js} +25 -18
- package/dist/iter-fest.readableStreamValues.js.map +1 -0
- package/dist/iter-fest.readableStreamValues.mjs +7 -0
- package/dist/iter-fest.readableStreamValues.mjs.map +1 -0
- package/dist/iter-fest.symbolObservable.d.mts +3 -0
- package/dist/iter-fest.symbolObservable.d.ts +3 -0
- package/dist/iter-fest.symbolObservable.js +42 -0
- package/dist/iter-fest.symbolObservable.js.map +1 -0
- package/dist/iter-fest.symbolObservable.mjs +7 -0
- package/dist/iter-fest.symbolObservable.mjs.map +1 -0
- package/package.json +406 -112
- package/dist/chunk-27NJVC7K.mjs.map +0 -1
- package/dist/chunk-44W7OTNE.mjs +0 -12
- package/dist/chunk-44W7OTNE.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-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-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.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.iterableAt.mjs.map → iter-fest.asyncGeneratorWithLastValue.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableConcat.mjs.map → iter-fest.asyncIteratorDrop.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableEntries.mjs.map → iter-fest.asyncIteratorEvery.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableEvery.mjs.map → iter-fest.asyncIteratorFilter.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFilter.mjs.map → iter-fest.asyncIteratorFind.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFind.mjs.map → iter-fest.asyncIteratorFlatMap.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindIndex.mjs.map → iter-fest.asyncIteratorForEach.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindLast.mjs.map → iter-fest.asyncIteratorFrom.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFindLastIndex.mjs.map → iter-fest.asyncIteratorMap.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableForEach.mjs.map → iter-fest.asyncIteratorReduce.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableIncludes.mjs.map → iter-fest.asyncIteratorSome.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableIndexOf.mjs.map → iter-fest.asyncIteratorTake.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableJoin.mjs.map → iter-fest.asyncIteratorToArray.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableKeys.mjs.map → iter-fest.asyncIteratorToAsyncIterable.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableMap.mjs.map → iter-fest.generatorWithLastValue.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableReduce.mjs.map → iter-fest.iterableWritableStream.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableSlice.mjs.map → iter-fest.iteratorAt.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableSome.mjs.map → iter-fest.iteratorConcat.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableToSpliced.mjs.map → iter-fest.iteratorDrop.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableToString.mjs.map → iter-fest.iteratorEntries.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -16,26 +16,27 @@ 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
|
+
|
|
21
|
+
| From | To | Function |
|
|
22
|
+
| -------------------------- | ----------------------- | ------------------------------------------------------------------------------- |
|
|
23
|
+
| `Iterator` | `IterableIterator` | [`iteratorToIterable`](#converting-an-iterator-to-iterable) |
|
|
24
|
+
| `AsyncIterator` | `AsyncIterableIterator` | [`asyncIteratorToAsyncIterable`](#converting-an-iterator-to-iterable) |
|
|
25
|
+
| `Observable` | `ReadableStream` | [`observableSubscribeAsReadable`](#converting-an-observable-to-readablestream) |
|
|
26
|
+
| `ReadableStream` | `AsyncIterableIterator` | [`readableStreamValues`](#converting-a-readablestream-to-asynciterableiterator) |
|
|
27
|
+
| `AsyncIterable` | `Observable` | [`observableFromAsync`](#converting-an-asynciterable-to-observable) |
|
|
28
|
+
| `AsyncIterable`/`Iterable` | `ReadableStream` | [`readableStreamFrom`](#converting-an-asynciterableiterable-to-readablestream) |
|
|
29
|
+
| `Observable` | `AsyncIterableIterator` | [`observableValues`](#converting-an-observable-to-asynciterableiterator) |
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
### Converting an iterator to iterable
|
|
22
32
|
|
|
23
33
|
```ts
|
|
24
|
-
|
|
25
|
-
import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
|
|
26
|
-
|
|
27
|
-
const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
|
|
34
|
+
function iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T>
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
|
|
31
|
-
console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
|
|
36
|
+
function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Converting an iterator to iterable
|
|
37
|
-
|
|
38
|
-
`iteratorToIterable` converts a pure iterator to `IterableIterator` and enable for-loop iteration.
|
|
39
|
+
`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
40
|
|
|
40
41
|
```ts
|
|
41
42
|
const iterate = (): Iterator<number> => {
|
|
@@ -44,10 +45,10 @@ const iterate = (): Iterator<number> => {
|
|
|
44
45
|
return {
|
|
45
46
|
next: () => {
|
|
46
47
|
if (++value <= 3) {
|
|
47
|
-
return {
|
|
48
|
+
return { value };
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
return { done: true, value: undefined }
|
|
51
|
+
return { done: true, value: undefined } satisfies IteratorResult<number>;
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
};
|
|
@@ -57,6 +58,244 @@ for (const value of iteratorToIterable(iterate())) {
|
|
|
57
58
|
}
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
### Converting an `AsyncIterable` to `Observable`
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
function observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`Observable.from` converts `Iterable` into `Observable`. However, it does not convert `AsyncIterable`.
|
|
70
|
+
|
|
71
|
+
`observableFromAsync` will convert `AsyncIterable` into `Observable`. It will try to restart the iteration by calling `[Symbol.asyncIterator]()`.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
async function* generate() {
|
|
75
|
+
yield 1;
|
|
76
|
+
yield 2;
|
|
77
|
+
yield 3;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const observable = observableFromAsync(generate());
|
|
81
|
+
const next = value => console.log(value);
|
|
82
|
+
|
|
83
|
+
observable.subscribe({ next }); // Prints "1", "2", "3".
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Note: `observableFromAsync` will call `[Symbol.asyncIterator]()` initially to restart the iteration where possible.
|
|
87
|
+
|
|
88
|
+
Note: It is not recommended to convert `AsyncGenerator` to an `Observable`. `AsyncGenerator` has more functionalities and `Observable` does not support many of them.
|
|
89
|
+
|
|
90
|
+
### Converting an `Observable` to `ReadableStream`
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
function observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`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.
|
|
97
|
+
|
|
98
|
+
Note: `Observable` is push-based and it does not support flow control. When converting to `ReadableStream`, the internal buffer could build up quickly.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const observable = Observable.from([1, 2, 3]);
|
|
102
|
+
const readable = observableSubscribeAsReadable(observable);
|
|
103
|
+
|
|
104
|
+
readable.pipeTo(stream.writable); // Will write 1, 2, 3.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Converting a `ReadableStream` to `AsyncIterableIterator`
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
function readableStreamValues`<T>(readable: ReadableStream<T>): AsyncIterableIterator<T>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`readableStreamValues` allow iteration of `ReadableStream` as an `AsyncIterableIterator`.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const readable = new ReadableStream({
|
|
117
|
+
start(controller) {
|
|
118
|
+
controller.enqueue(1);
|
|
119
|
+
controller.enqueue(2);
|
|
120
|
+
},
|
|
121
|
+
pull(controller) {
|
|
122
|
+
controller.enqueue(3);
|
|
123
|
+
controller.close();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const iterable = readableStreamValues(readable);
|
|
128
|
+
|
|
129
|
+
for await (const value of iterable) {
|
|
130
|
+
console.log(value); // Prints "1", "2", "3".
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Note: The stream will be locked as soon as the iterable is created. When using iterating outside of for-loop, make sure to call `AsyncIterator.return` when the iteration is done to release the lock on the stream.
|
|
135
|
+
|
|
136
|
+
Note: `[Symbol.asyncIterator]()` will not restart the stream.
|
|
137
|
+
|
|
138
|
+
### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
function readableStreamFrom<T>(anyIterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> Notes: this feature is part of [Streams Standard](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static).
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const iterable = [1, 2, 3].values();
|
|
148
|
+
const readable = readableStreamFrom(iterable);
|
|
149
|
+
|
|
150
|
+
readable.pipeTo(stream.writable); // Will write 1, 2, 3.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Note: `readableStreamFrom()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
|
|
154
|
+
|
|
155
|
+
### Converting an `Observable` to `AsyncIterableIterator`
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
function observableValues<T>(observable: Observable<T>): AsyncIterableIterator<T>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`Observable` can be converted to `AsyncIterableIterator` for easier consumption.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const observable = Observable.from([1, 2, 3]);
|
|
165
|
+
const iterable = observableValues(readable);
|
|
166
|
+
|
|
167
|
+
for await (const value of iterable) {
|
|
168
|
+
console.log(value); // Prints "1", "2", "3".
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Note: `Observable` is push-based and it does not support flow control. When converting to `AsyncIterableIterator`, the internal buffer could build up quickly.
|
|
173
|
+
|
|
174
|
+
Note: when the observable throw an exception via `observer.error()`, it will become rejection of `AsyncIterator.next()`. The exception will be hoisted back to the caller.
|
|
175
|
+
|
|
176
|
+
## Others
|
|
177
|
+
|
|
178
|
+
### Typed `Observable`
|
|
179
|
+
|
|
180
|
+
`Observable` and `Symbol.observable` is re-exported from `core-js-pure` with proper type definitions.
|
|
181
|
+
|
|
182
|
+
### Producer-consumer queue
|
|
183
|
+
|
|
184
|
+
`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.
|
|
185
|
+
|
|
186
|
+
`IterableWritableStream` supports multiple consumers and continuation:
|
|
187
|
+
|
|
188
|
+
- 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
|
|
189
|
+
- Continuation: when the last consumer disconnected while producer keep pushing new jobs, the next consumer will pick up where the last consumer left
|
|
190
|
+
|
|
191
|
+
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.
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
const iterable = new IterableWritableStream();
|
|
195
|
+
const writer = iterable.getWriter();
|
|
196
|
+
|
|
197
|
+
(async function consumer() {
|
|
198
|
+
for await (const value of iterable) {
|
|
199
|
+
console.log(value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
console.log('Done');
|
|
203
|
+
})();
|
|
204
|
+
|
|
205
|
+
(async function producer() {
|
|
206
|
+
writer.write(1);
|
|
207
|
+
writer.write(2);
|
|
208
|
+
writer.write(3);
|
|
209
|
+
writer.close();
|
|
210
|
+
})();
|
|
211
|
+
|
|
212
|
+
// Prints "1", "2", "3", "Done".
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Using for-loop with generator
|
|
216
|
+
|
|
217
|
+
Compare to `Iterator`, `Generator` offers advanced capability.
|
|
218
|
+
|
|
219
|
+
When using for-loop with generator, the last value return from the generator is lost.
|
|
220
|
+
|
|
221
|
+
The `generatorWithLastValue()` and `asyncGeneratorWithLastValue()` helps bridge the for-loop usage by capturing the value returned as `{ done: true }` and make it accessible via `lastValue()`.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const generator = generatorWithLastValue(
|
|
225
|
+
(function* () {
|
|
226
|
+
yield 1; // { done: false, value: 1 }
|
|
227
|
+
yield 2; // { done: false, value: 2 }
|
|
228
|
+
yield 3; // { done: false, value: 3 }
|
|
229
|
+
|
|
230
|
+
return 'end'; // { done: true, value: 'end' }
|
|
231
|
+
})()
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
for (const value of generator) {
|
|
235
|
+
console.log(value); // Prints "1", "2", "3".
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
console.log(generator.lastValue()); // Prints "end".
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
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.
|
|
242
|
+
|
|
243
|
+
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()`.
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
const generator = generatorWithLastValue(
|
|
247
|
+
(function* () {
|
|
248
|
+
// ...
|
|
249
|
+
})()[Symbol.iterator]() // Creates a fresh iteration.
|
|
250
|
+
);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Adding types to `core-js-pure`
|
|
254
|
+
|
|
255
|
+
We added types to [Iterator Helpers](https://github.com/tc39/proposal-iterator-helpers) and [Async Iterator Helpers](https://github.com/tc39/proposal-async-iterator-helpers) implementation from `core-js-pure`:
|
|
256
|
+
|
|
257
|
+
- [`Iterator.drop`](https://tc39.es/ecma262/#sec-array.prototype.drop)
|
|
258
|
+
- [`Iterator.every`](https://tc39.es/ecma262/#sec-array.prototype.every)
|
|
259
|
+
- [`Iterator.filter`](https://tc39.es/ecma262/#sec-array.prototype.filter)
|
|
260
|
+
- [`Iterator.find`](https://tc39.es/ecma262/#sec-array.prototype.find)
|
|
261
|
+
- [`Iterator.flatMap`](https://tc39.es/ecma262/#sec-array.prototype.flatmap)
|
|
262
|
+
- [`Iterator.forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach)
|
|
263
|
+
- [`Iterator.from`](https://tc39.es/ecma262/#sec-array.prototype.from)
|
|
264
|
+
- [`Iterator.map`](https://tc39.es/ecma262/#sec-array.prototype.map)
|
|
265
|
+
- [`Iterator.reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce)
|
|
266
|
+
- [`Iterator.some`](https://tc39.es/ecma262/#sec-array.prototype.some)
|
|
267
|
+
- [`Iterator.take`](https://tc39.es/ecma262/#sec-array.prototype.take)
|
|
268
|
+
- [`Iterator.toArray`](https://tc39.es/ecma262/#sec-array.prototype.toarray)
|
|
269
|
+
- [`AsyncIterator.drop`](https://tc39.es/ecma262/#sec-array.prototype.drop)
|
|
270
|
+
- [`AsyncIterator.every`](https://tc39.es/ecma262/#sec-array.prototype.every)
|
|
271
|
+
- [`AsyncIterator.filter`](https://tc39.es/ecma262/#sec-array.prototype.filter)
|
|
272
|
+
- [`AsyncIterator.find`](https://tc39.es/ecma262/#sec-array.prototype.find)
|
|
273
|
+
- [`AsyncIterator.flatMap`](https://tc39.es/ecma262/#sec-array.prototype.flatmap)
|
|
274
|
+
- [`AsyncIterator.forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach)
|
|
275
|
+
- [`AsyncIterator.from`](https://tc39.es/ecma262/#sec-array.prototype.from)
|
|
276
|
+
- [`AsyncIterator.map`](https://tc39.es/ecma262/#sec-array.prototype.map)
|
|
277
|
+
- [`AsyncIterator.reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce)
|
|
278
|
+
- [`AsyncIterator.some`](https://tc39.es/ecma262/#sec-array.prototype.some)
|
|
279
|
+
- [`AsyncIterator.take`](https://tc39.es/ecma262/#sec-array.prototype.take)
|
|
280
|
+
- [`AsyncIterator.toArray`](https://tc39.es/ecma262/#sec-array.prototype.toarray)
|
|
281
|
+
|
|
282
|
+
## `Array.prototype` ports
|
|
283
|
+
|
|
284
|
+
We ported majority of functions from `Array.prototype.*` to `iterator*`.
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
import { iteratorIncludes, iteratorReduce } from 'iter-fest'; // Via default exports.
|
|
288
|
+
import { iteratorSome } from 'iter-fest/iteratorSome'; // Via named exports.
|
|
289
|
+
|
|
290
|
+
const iterator: iterator<number> = [1, 2, 3, 4, 5].values();
|
|
291
|
+
|
|
292
|
+
console.log(iteratorIncludes(iterator, 3)); // Prints "true".
|
|
293
|
+
console.log(iteratorReduce(iterator, (sum, value) => sum + value, 0)); // Prints "15".
|
|
294
|
+
console.log(iteratorSome(iterator, value => value % 2)); // Prints "true".
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
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).
|
|
298
|
+
|
|
60
299
|
## Behaviors
|
|
61
300
|
|
|
62
301
|
### How this compares to the TC39 proposals?
|
|
@@ -72,27 +311,27 @@ Majority of functions should work the same way with same complexity and performa
|
|
|
72
311
|
There are minor differences on some functions:
|
|
73
312
|
|
|
74
313
|
- `findLast` and `findLastIndex`
|
|
75
|
-
- Instead of iterating from the right side,
|
|
76
|
-
- Thus, with an
|
|
314
|
+
- Instead of iterating from the right side, iterators must start from left side
|
|
315
|
+
- Thus, with an iterator of 5 items, `predicate` will be called exactly 5 times with `O(N)` complexity
|
|
77
316
|
- In contrast, its counterpart in `Array` will be called between 1 and 5 times with `O(log N)` complexity
|
|
78
317
|
- `at`, `includes`, `indexOf`, `slice`, and `toSpliced`
|
|
79
318
|
- Index arguments cannot be negative finite number
|
|
80
|
-
- Negative finite number means traversing from right side, which an iterator
|
|
319
|
+
- Negative finite number means traversing from right side, which an iterator may not have an end
|
|
81
320
|
- Infinites, zeroes, and positive numbers are supported
|
|
82
321
|
|
|
83
322
|
### Why `Array.prototype.push` is not ported?
|
|
84
323
|
|
|
85
|
-
Some functions that modify the array are not ported, such as, `copyWithin`, `fill`, `pop`, `push`, `reverse`, `shift`, `splice`, `unshift`, etc.
|
|
324
|
+
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.
|
|
86
325
|
|
|
87
|
-
Some functions that do not have actual functionality in the
|
|
326
|
+
Some functions that do not have actual functionality in the iterator world are not ported, such as, `values`, etc.
|
|
88
327
|
|
|
89
328
|
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.
|
|
90
329
|
|
|
91
330
|
If you think a specific function should be ported, please submit a pull request to us.
|
|
92
331
|
|
|
93
|
-
### How about asynchronous
|
|
332
|
+
### How about asynchronous iterators?
|
|
94
333
|
|
|
95
|
-
Yes, this is on our roadmap. This will enable traverse
|
|
334
|
+
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.
|
|
96
335
|
|
|
97
336
|
### How about functions outside of `Array.prototype`?
|
|
98
337
|
|
|
@@ -105,18 +344,21 @@ Generator has more functionalities than iterator and array. It is not recommende
|
|
|
105
344
|
- Generator can define the return value
|
|
106
345
|
- `return { done: true, value: 'the very last value' }`
|
|
107
346
|
- Iterating generator using for-loop will not get any values from `{ done: true }`
|
|
347
|
+
- The `generatorWithLastValue()` will help capturing and retrieving the last return value
|
|
108
348
|
- Generator can receive feedback values from its iterator
|
|
109
349
|
- `generator.next('something')`, the feedback can be assigned to variable via `const feedback = yield;`
|
|
110
350
|
- For-loop cannot send feedbacks to generator
|
|
111
351
|
|
|
112
352
|
### When should I use `Iterable`, `IterableIterator` and `Iterator`?
|
|
113
353
|
|
|
114
|
-
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`.
|
|
354
|
+
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.
|
|
115
355
|
|
|
116
356
|
```ts
|
|
117
|
-
function
|
|
357
|
+
function myFunction<T>(input: Iterable<T>): IterableIterator<T>;
|
|
118
358
|
```
|
|
119
359
|
|
|
360
|
+
`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.
|
|
361
|
+
|
|
120
362
|
### What is on the roadmap?
|
|
121
363
|
|
|
122
364
|
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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/asyncIteratorEvery.ts
|
|
2
|
+
import every from "core-js-pure/full/async-iterator/every";
|
|
3
|
+
function asyncIteratorEvery(iterator, predicate) {
|
|
4
|
+
return every(iterator, predicate);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
asyncIteratorEvery
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-4RT2FROS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asyncIteratorEvery.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport every from 'core-js-pure/full/async-iterator/every';\n\n/**\n * Determines whether all the members of an iterator satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterator until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorEvery<T>(\n asyncIterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => Promise<boolean>\n): Promise<boolean>;\n\n/**\n * Determines whether all the members of an iterator satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterator until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterator.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorEvery<T>(\n iterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => Promise<unknown>\n): Promise<boolean>;\n\nexport function asyncIteratorEvery<T>(\n iterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => Promise<unknown>\n): Promise<boolean> {\n return every(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,WAAW;AAiCX,SAAS,mBACd,UACA,WACkB;AAClB,SAAO,MAAM,UAAU,SAAS;AAClC;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/asyncIteratorFilter.ts
|
|
2
|
+
import filter from "core-js-pure/full/async-iterator/filter";
|
|
3
|
+
function asyncIteratorFilter(asyncIterator, predicate) {
|
|
4
|
+
return filter(asyncIterator, predicate);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
asyncIteratorFilter
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-4ZBMXHD6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asyncIteratorFilter.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport filter from 'core-js-pure/full/async-iterator/filter';\n\n/**\n * Returns the elements of an iterator that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorFilter<T, S extends T>(\n asyncIterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => value is S\n): AsyncIterableIterator<S>;\n\n/**\n * Returns the elements of an iterator that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorFilter<T>(\n asyncIterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => unknown\n): AsyncIterableIterator<T>;\n\nexport function asyncIteratorFilter<T, S extends T>(\n asyncIterator: AsyncIterator<T>,\n predicate: (value: T, index: number) => unknown\n): AsyncIterableIterator<S> {\n return filter(asyncIterator, predicate);\n}\n"],"mappings":";AACA,OAAO,YAAY;AA0BZ,SAAS,oBACd,eACA,WAC0B;AAC1B,SAAO,OAAO,eAAe,SAAS;AACxC;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readableStreamValues
|
|
3
|
+
} from "./chunk-RVIERPEV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
observableSubscribeAsReadable
|
|
6
|
+
} from "./chunk-EIIP7YWB.mjs";
|
|
7
|
+
|
|
8
|
+
// src/observableValues.ts
|
|
9
|
+
function observableValues(observable) {
|
|
10
|
+
const readable = observableSubscribeAsReadable(observable);
|
|
11
|
+
const iterable = readableStreamValues(readable);
|
|
12
|
+
const cancellableIterable = {
|
|
13
|
+
[Symbol.asyncIterator]() {
|
|
14
|
+
return cancellableIterable;
|
|
15
|
+
},
|
|
16
|
+
next() {
|
|
17
|
+
return iterable.next();
|
|
18
|
+
},
|
|
19
|
+
return() {
|
|
20
|
+
var _a;
|
|
21
|
+
try {
|
|
22
|
+
return ((_a = iterable.return) == null ? void 0 : _a.call(iterable)) ?? Promise.resolve({ done: true, value: void 0 });
|
|
23
|
+
} finally {
|
|
24
|
+
readable.cancel();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
throw(error) {
|
|
28
|
+
var _a;
|
|
29
|
+
return ((_a = iterable.throw) == null ? void 0 : _a.call(iterable, error)) ?? Promise.resolve({ done: true, value: void 0 });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return cancellableIterable;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
observableValues
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-72AEHTPQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/observableValues.ts"],"sourcesContent":["import type { Observable } from './Observable';\nimport { observableSubscribeAsReadable } from './observableSubscribeAsReadable';\nimport { readableStreamValues } from './readableStreamValues';\n\nexport function observableValues<T>(observable: Observable<T>): AsyncIterableIterator<T> {\n const readable = observableSubscribeAsReadable(observable);\n const iterable = readableStreamValues(readable);\n\n const cancellableIterable: AsyncIterableIterator<T> = {\n [Symbol.asyncIterator]() {\n return cancellableIterable;\n },\n next() {\n return iterable.next();\n },\n return() {\n try {\n return iterable.return?.() ?? Promise.resolve({ done: true, value: undefined });\n } finally {\n readable.cancel();\n }\n },\n throw(error) {\n return iterable.throw?.(error) ?? Promise.resolve({ done: true, value: undefined });\n }\n };\n\n return cancellableIterable;\n}\n"],"mappings":";;;;;;;;AAIO,SAAS,iBAAoB,YAAqD;AACvF,QAAM,WAAW,8BAA8B,UAAU;AACzD,QAAM,WAAW,qBAAqB,QAAQ;AAE9C,QAAM,sBAAgD;AAAA,IACpD,CAAC,OAAO,aAAa,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,IACA,OAAO;AACL,aAAO,SAAS,KAAK;AAAA,IACvB;AAAA,IACA,SAAS;AAfb;AAgBM,UAAI;AACF,iBAAO,cAAS,WAAT,sCAAuB,QAAQ,QAAQ,EAAE,MAAM,MAAM,OAAO,OAAU,CAAC;AAAA,MAChF,UAAE;AACA,iBAAS,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,IACA,MAAM,OAAO;AAtBjB;AAuBM,eAAO,cAAS,UAAT,kCAAiB,WAAU,QAAQ,QAAQ,EAAE,MAAM,MAAM,OAAO,OAAU,CAAC;AAAA,IACpF;AAAA,EACF;AAEA,SAAO;AACT;","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,10 @@
|
|
|
1
|
+
// src/asyncIteratorTake.ts
|
|
2
|
+
import take from "core-js-pure/full/async-iterator/take";
|
|
3
|
+
function asyncIteratorTake(asyncIterator, limit) {
|
|
4
|
+
return take(asyncIterator, limit);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
asyncIteratorTake
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-AOZVPHE4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asyncIteratorTake.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport take from 'core-js-pure/full/async-iterator/take';\n\n/**\n * `take` takes an integer as an argument. It returns an iterator that produces, at most, the given number of elements produced by the underlying iterator.\n *\n * @param limit\n *\n * @return Returns an iterator with items from the original iterator from 0 until the limit.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorTake<T>(asyncIterator: AsyncIterator<T>, limit: number): AsyncIterator<T> {\n return take(asyncIterator, limit);\n}\n"],"mappings":";AACA,OAAO,UAAU;AAWV,SAAS,kBAAqB,eAAiC,OAAiC;AACrG,SAAO,KAAK,eAAe,KAAK;AAClC;","names":[]}
|
|
@@ -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":[]}
|