rubico 2.7.2 → 2.7.4
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 +14 -17
- package/Transducer.d.ts +10 -10
- package/Transducer.js +65 -69
- package/__.js +1 -1
- package/_internal/FlatMappingIterator.js +1 -1
- package/_internal/MappingIterator.d.ts +1 -1
- package/_internal/MappingIterator.js +1 -1
- package/_internal/arrayFilter.js +6 -6
- package/_internal/arrayFilterIndexes.js +7 -7
- package/_internal/arrayFilterWithIndex.js +6 -6
- package/_internal/arrayFind.js +7 -7
- package/_internal/arrayFlatten.js +25 -25
- package/_internal/arrayForEach.d.ts +1 -1
- package/_internal/arrayForEach.js +1 -1
- package/_internal/arrayForEachSeries.js +1 -1
- package/_internal/arrayMap.d.ts +2 -2
- package/_internal/arrayMap.js +5 -5
- package/_internal/arrayMapPool.d.ts +1 -1
- package/_internal/arrayMapPool.js +10 -10
- package/_internal/arrayMapRate.js +4 -4
- package/_internal/arrayMapSeries.d.ts +1 -1
- package/_internal/arrayMapSeries.js +8 -8
- package/_internal/arrayMapWithIndex.js +4 -4
- package/_internal/arrayReduce.js +1 -1
- package/_internal/asyncGeneratorFunctionForEach.js +3 -3
- package/_internal/asyncGeneratorFunctionMap.js +3 -3
- package/_internal/asyncIteratorFind.js +3 -3
- package/_internal/asyncIteratorForEach.d.ts +1 -1
- package/_internal/asyncIteratorForEach.js +3 -3
- package/_internal/asyncIteratorForEachSeries.js +3 -3
- package/_internal/asyncIteratorToArray.js +2 -2
- package/_internal/copyDeep.js +12 -12
- package/_internal/funcAll.js +3 -3
- package/_internal/funcAllSeries.js +6 -6
- package/_internal/funcObjectAll.js +4 -4
- package/_internal/functionArrayAll.js +3 -3
- package/_internal/functionArrayAllSeries.js +6 -6
- package/_internal/functionObjectAll.js +4 -4
- package/_internal/generatorFunctionForEach.js +3 -3
- package/_internal/generatorFunctionMap.js +3 -3
- package/_internal/generatorFunctionReduce.js +1 -1
- package/_internal/iteratorEvery.js +2 -2
- package/_internal/iteratorFind.js +7 -7
- package/_internal/iteratorForEach.d.ts +1 -1
- package/_internal/iteratorForEach.js +3 -3
- package/_internal/iteratorForEachSeries.js +1 -1
- package/_internal/iteratorReduce.d.ts +1 -1
- package/_internal/iteratorReduce.js +2 -2
- package/_internal/iteratorSome.js +2 -2
- package/_internal/mapFilter.js +4 -4
- package/_internal/mapMap.d.ts +1 -1
- package/_internal/mapMap.js +6 -6
- package/_internal/mapMapPool.js +10 -10
- package/_internal/mapMapSeries.js +10 -10
- package/_internal/objectFilter.js +6 -6
- package/_internal/objectFlatMap.d.ts +1 -1
- package/_internal/objectFlatMap.js +1 -1
- package/_internal/objectFlatten.js +14 -14
- package/_internal/objectMap.js +3 -3
- package/_internal/objectMapOwn.js +3 -3
- package/_internal/objectMapPool.js +10 -10
- package/_internal/objectMapSeries.js +9 -9
- package/_internal/objectReduce.d.ts +1 -1
- package/_internal/objectReduce.js +2 -2
- package/_internal/reducerAllSync.d.ts +2 -2
- package/_internal/reducerAllSync.js +2 -2
- package/_internal/reducerAnySync.d.ts +1 -1
- package/_internal/reducerAnySync.js +2 -2
- package/_internal/reducerConcat.d.ts +1 -1
- package/_internal/reducerConcat.js +4 -4
- package/_internal/reducerConcatSync.js +2 -2
- package/_internal/reducerEvery.d.ts +2 -2
- package/_internal/reducerEvery.js +4 -4
- package/_internal/reducerFilter.d.ts +2 -2
- package/_internal/reducerFilter.js +5 -5
- package/_internal/reducerFlatten.js +3 -3
- package/_internal/reducerForEach.d.ts +2 -2
- package/_internal/reducerForEach.js +5 -5
- package/_internal/reducerMap.d.ts +1 -1
- package/_internal/reducerMap.js +5 -5
- package/_internal/reducerSome.d.ts +2 -2
- package/_internal/reducerSome.js +4 -4
- package/_internal/reducerTryCatch.d.ts +2 -2
- package/_internal/reducerTryCatch.js +8 -8
- package/_internal/setFilter.d.ts +1 -1
- package/_internal/setFilter.js +5 -5
- package/_internal/setFlatten.js +24 -24
- package/_internal/setMap.d.ts +1 -1
- package/_internal/setMap.js +6 -6
- package/_internal/setMapPool.js +9 -9
- package/_internal/setMapSeries.js +10 -10
- package/_internal/streamFlatExtend.js +25 -25
- package/_internal/streamFlatMap.js +2 -2
- package/all.js +29 -30
- package/and.js +27 -13
- package/assign.js +15 -23
- package/compose.js +7 -5
- package/curry.js +5 -12
- package/dist/Transducer.es.js +24 -24
- package/dist/Transducer.es.min.js +1 -1
- package/dist/Transducer.js +24 -24
- package/dist/Transducer.min.js +1 -1
- package/dist/Transducer.mjs +24 -24
- package/dist/__.es.js +1 -1
- package/dist/__.es.min.js +1 -1
- package/dist/__.js +1 -1
- package/dist/__.min.js +1 -1
- package/dist/__.mjs +1 -1
- package/dist/all.es.js +14 -14
- package/dist/all.es.min.js +1 -1
- package/dist/all.js +14 -14
- package/dist/all.min.js +1 -1
- package/dist/all.mjs +14 -14
- package/dist/always.es.js +1 -1
- package/dist/always.es.min.js +1 -1
- package/dist/always.js +1 -1
- package/dist/always.min.js +1 -1
- package/dist/always.mjs +1 -1
- package/dist/and.es.js +1 -1
- package/dist/and.es.min.js +1 -1
- package/dist/and.js +1 -1
- package/dist/and.min.js +1 -1
- package/dist/and.mjs +1 -1
- package/dist/assign.es.js +5 -5
- package/dist/assign.es.min.js +1 -1
- package/dist/assign.js +5 -5
- package/dist/assign.min.js +1 -1
- package/dist/assign.mjs +5 -5
- package/dist/compose.es.js +1 -1
- package/dist/compose.es.min.js +1 -1
- package/dist/compose.js +1 -1
- package/dist/compose.min.js +1 -1
- package/dist/compose.mjs +1 -1
- package/dist/curry.es.js +1 -1
- package/dist/curry.es.min.js +1 -1
- package/dist/curry.js +1 -1
- package/dist/curry.min.js +1 -1
- package/dist/curry.mjs +1 -1
- package/dist/eq.es.js +1 -1
- package/dist/eq.es.min.js +1 -1
- package/dist/eq.js +1 -1
- package/dist/eq.min.js +1 -1
- package/dist/eq.mjs +1 -1
- package/dist/every.es.js +7 -7
- package/dist/every.es.min.js +1 -1
- package/dist/every.js +7 -7
- package/dist/every.min.js +1 -1
- package/dist/every.mjs +7 -7
- package/dist/filter.es.js +21 -21
- package/dist/filter.es.min.js +1 -1
- package/dist/filter.js +21 -21
- package/dist/filter.min.js +1 -1
- package/dist/filter.mjs +21 -21
- package/dist/flatMap.es.js +82 -82
- package/dist/flatMap.es.min.js +1 -1
- package/dist/flatMap.js +82 -82
- package/dist/flatMap.min.js +1 -1
- package/dist/flatMap.mjs +82 -82
- package/dist/forEach.es.js +7 -7
- package/dist/forEach.es.min.js +1 -1
- package/dist/forEach.js +7 -7
- package/dist/forEach.min.js +1 -1
- package/dist/forEach.mjs +7 -7
- package/dist/get.es.js +1 -1
- package/dist/get.es.min.js +1 -1
- package/dist/get.js +1 -1
- package/dist/get.min.js +1 -1
- package/dist/get.mjs +1 -1
- package/dist/gt.es.js +1 -1
- package/dist/gt.es.min.js +1 -1
- package/dist/gt.js +1 -1
- package/dist/gt.min.js +1 -1
- package/dist/gt.mjs +1 -1
- package/dist/gte.es.js +1 -1
- package/dist/gte.es.min.js +1 -1
- package/dist/gte.js +1 -1
- package/dist/gte.min.js +1 -1
- package/dist/gte.mjs +1 -1
- package/dist/lt.es.js +1 -1
- package/dist/lt.es.min.js +1 -1
- package/dist/lt.js +1 -1
- package/dist/lt.min.js +1 -1
- package/dist/lt.mjs +1 -1
- package/dist/lte.es.js +1 -1
- package/dist/lte.es.min.js +1 -1
- package/dist/lte.js +1 -1
- package/dist/lte.min.js +1 -1
- package/dist/lte.mjs +1 -1
- package/dist/map.es.js +83 -83
- package/dist/map.es.min.js +1 -1
- package/dist/map.js +83 -83
- package/dist/map.min.js +1 -1
- package/dist/map.mjs +83 -83
- package/dist/not.es.js +4 -2
- package/dist/not.es.min.js +2 -2
- package/dist/not.js +4 -2
- package/dist/not.min.js +2 -2
- package/dist/not.mjs +4 -2
- package/dist/omit.es.js +13 -13
- package/dist/omit.es.min.js +1 -1
- package/dist/omit.js +13 -13
- package/dist/omit.min.js +1 -1
- package/dist/omit.mjs +13 -13
- package/dist/or.es.js +1 -1
- package/dist/or.es.min.js +1 -1
- package/dist/or.js +1 -1
- package/dist/or.min.js +1 -1
- package/dist/or.mjs +1 -1
- package/dist/pick.es.js +1 -1
- package/dist/pick.es.min.js +1 -1
- package/dist/pick.js +1 -1
- package/dist/pick.min.js +1 -1
- package/dist/pick.mjs +1 -1
- package/dist/pipe.es.js +1 -1
- package/dist/pipe.es.min.js +1 -1
- package/dist/pipe.js +1 -1
- package/dist/pipe.min.js +1 -1
- package/dist/pipe.mjs +1 -1
- package/dist/reduce.es.js +5 -5
- package/dist/reduce.es.min.js +1 -1
- package/dist/reduce.js +5 -5
- package/dist/reduce.min.js +1 -1
- package/dist/reduce.mjs +5 -5
- package/dist/rubico.es.js +218 -216
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +218 -216
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +218 -216
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +218 -216
- package/dist/set.es.js +1 -1
- package/dist/set.es.min.js +1 -1
- package/dist/set.js +1 -1
- package/dist/set.min.js +1 -1
- package/dist/set.mjs +1 -1
- package/dist/some.es.js +8 -8
- package/dist/some.es.min.js +1 -1
- package/dist/some.js +8 -8
- package/dist/some.min.js +1 -1
- package/dist/some.mjs +8 -8
- package/dist/switchCase.es.js +1 -1
- package/dist/switchCase.es.min.js +1 -1
- package/dist/switchCase.js +1 -1
- package/dist/switchCase.min.js +1 -1
- package/dist/switchCase.mjs +1 -1
- package/dist/tap.es.js +1 -1
- package/dist/tap.es.min.js +1 -1
- package/dist/tap.js +1 -1
- package/dist/tap.min.js +1 -1
- package/dist/tap.mjs +1 -1
- package/dist/thunkify.es.js +1 -1
- package/dist/thunkify.es.min.js +1 -1
- package/dist/thunkify.js +1 -1
- package/dist/thunkify.min.js +1 -1
- package/dist/thunkify.mjs +1 -1
- package/dist/transform.es.js +5 -5
- package/dist/transform.es.min.js +1 -1
- package/dist/transform.js +5 -5
- package/dist/transform.min.js +1 -1
- package/dist/transform.mjs +5 -5
- package/dist/tryCatch.es.js +1 -1
- package/dist/tryCatch.es.min.js +1 -1
- package/dist/tryCatch.js +1 -1
- package/dist/tryCatch.min.js +1 -1
- package/dist/tryCatch.mjs +1 -1
- package/dist/x/append.es.js +8 -8
- package/dist/x/append.es.min.js +1 -1
- package/dist/x/append.js +8 -8
- package/dist/x/append.min.js +1 -1
- package/dist/x/append.mjs +8 -8
- package/dist/x/callProp.es.js +1 -1
- package/dist/x/callProp.es.min.js +1 -1
- package/dist/x/callProp.js +1 -1
- package/dist/x/callProp.min.js +1 -1
- package/dist/x/callProp.mjs +1 -1
- package/dist/x/defaultsDeep.es.js +69 -37
- package/dist/x/defaultsDeep.es.min.js +2 -2
- package/dist/x/defaultsDeep.js +69 -37
- package/dist/x/defaultsDeep.min.js +2 -2
- package/dist/x/defaultsDeep.mjs +69 -37
- package/dist/x/differenceWith.es.js +14 -14
- package/dist/x/differenceWith.es.min.js +1 -1
- package/dist/x/differenceWith.js +14 -14
- package/dist/x/differenceWith.min.js +1 -1
- package/dist/x/differenceWith.mjs +14 -14
- package/dist/x/filterOut.es.js +24 -22
- package/dist/x/filterOut.es.min.js +2 -2
- package/dist/x/filterOut.js +24 -22
- package/dist/x/filterOut.min.js +2 -2
- package/dist/x/filterOut.mjs +24 -22
- package/dist/x/find.es.js +18 -18
- package/dist/x/find.es.min.js +1 -1
- package/dist/x/find.js +18 -18
- package/dist/x/find.min.js +1 -1
- package/dist/x/find.mjs +18 -18
- package/dist/x/findIndex.es.js +1 -1
- package/dist/x/findIndex.es.min.js +1 -1
- package/dist/x/findIndex.js +1 -1
- package/dist/x/findIndex.min.js +1 -1
- package/dist/x/findIndex.mjs +1 -1
- package/dist/x/first.es.js +1 -1
- package/dist/x/first.es.min.js +1 -1
- package/dist/x/first.js +1 -1
- package/dist/x/first.min.js +1 -1
- package/dist/x/first.mjs +1 -1
- package/dist/x/flatten.es.js +82 -82
- package/dist/x/flatten.es.min.js +1 -1
- package/dist/x/flatten.js +82 -82
- package/dist/x/flatten.min.js +1 -1
- package/dist/x/flatten.mjs +82 -82
- package/dist/x/groupBy.es.js +17 -17
- package/dist/x/groupBy.es.min.js +1 -1
- package/dist/x/groupBy.js +17 -17
- package/dist/x/groupBy.min.js +1 -1
- package/dist/x/groupBy.mjs +17 -17
- package/dist/x/has.es.js +1 -1
- package/dist/x/has.es.min.js +1 -1
- package/dist/x/has.js +1 -1
- package/dist/x/has.min.js +1 -1
- package/dist/x/has.mjs +1 -1
- package/dist/x/identity.es.js +1 -1
- package/dist/x/identity.es.min.js +1 -1
- package/dist/x/identity.js +1 -1
- package/dist/x/identity.min.js +1 -1
- package/dist/x/identity.mjs +1 -1
- package/dist/x/includes.es.js +1 -1
- package/dist/x/includes.es.min.js +1 -1
- package/dist/x/includes.js +1 -1
- package/dist/x/includes.min.js +1 -1
- package/dist/x/includes.mjs +1 -1
- package/dist/x/isDeepEqual.es.js +1 -1
- package/dist/x/isDeepEqual.es.min.js +1 -1
- package/dist/x/isDeepEqual.js +1 -1
- package/dist/x/isDeepEqual.min.js +1 -1
- package/dist/x/isDeepEqual.mjs +1 -1
- package/dist/x/isEmpty.es.js +1 -1
- package/dist/x/isEmpty.es.min.js +1 -1
- package/dist/x/isEmpty.js +1 -1
- package/dist/x/isEmpty.min.js +1 -1
- package/dist/x/isEmpty.mjs +1 -1
- package/dist/x/isEqual.es.js +1 -1
- package/dist/x/isEqual.es.min.js +1 -1
- package/dist/x/isEqual.js +1 -1
- package/dist/x/isEqual.min.js +1 -1
- package/dist/x/isEqual.mjs +1 -1
- package/dist/x/isFunction.es.js +1 -1
- package/dist/x/isFunction.es.min.js +1 -1
- package/dist/x/isFunction.js +1 -1
- package/dist/x/isFunction.min.js +1 -1
- package/dist/x/isFunction.mjs +1 -1
- package/dist/x/isIn.es.js +1 -1
- package/dist/x/isIn.es.min.js +1 -1
- package/dist/x/isIn.js +1 -1
- package/dist/x/isIn.min.js +1 -1
- package/dist/x/isIn.mjs +1 -1
- package/dist/x/isObject.es.js +1 -1
- package/dist/x/isObject.es.min.js +1 -1
- package/dist/x/isObject.js +1 -1
- package/dist/x/isObject.min.js +1 -1
- package/dist/x/isObject.mjs +1 -1
- package/dist/x/isString.es.js +1 -1
- package/dist/x/isString.es.min.js +1 -1
- package/dist/x/isString.js +1 -1
- package/dist/x/isString.min.js +1 -1
- package/dist/x/isString.mjs +1 -1
- package/dist/x/keys.es.js +1 -1
- package/dist/x/keys.es.min.js +1 -1
- package/dist/x/keys.js +1 -1
- package/dist/x/keys.min.js +1 -1
- package/dist/x/keys.mjs +1 -1
- package/dist/x/last.es.js +1 -1
- package/dist/x/last.es.min.js +1 -1
- package/dist/x/last.js +1 -1
- package/dist/x/last.min.js +1 -1
- package/dist/x/last.mjs +1 -1
- package/dist/x/maxBy.es.js +6 -6
- package/dist/x/maxBy.es.min.js +1 -1
- package/dist/x/maxBy.js +6 -6
- package/dist/x/maxBy.min.js +1 -1
- package/dist/x/maxBy.mjs +6 -6
- package/dist/x/noop.es.js +1 -1
- package/dist/x/noop.es.min.js +1 -1
- package/dist/x/noop.js +1 -1
- package/dist/x/noop.min.js +1 -1
- package/dist/x/noop.mjs +1 -1
- package/dist/x/pluck.es.js +83 -83
- package/dist/x/pluck.es.min.js +1 -1
- package/dist/x/pluck.js +83 -83
- package/dist/x/pluck.min.js +1 -1
- package/dist/x/pluck.mjs +83 -83
- package/dist/x/prepend.es.js +8 -8
- package/dist/x/prepend.es.min.js +1 -1
- package/dist/x/prepend.js +8 -8
- package/dist/x/prepend.min.js +1 -1
- package/dist/x/prepend.mjs +8 -8
- package/dist/x/size.es.js +1 -1
- package/dist/x/size.es.min.js +1 -1
- package/dist/x/size.js +1 -1
- package/dist/x/size.min.js +1 -1
- package/dist/x/size.mjs +1 -1
- package/dist/x/trace.es.js +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +1 -1
- package/dist/x/trace.mjs +1 -1
- package/dist/x/unionWith.es.js +39 -39
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +39 -39
- package/dist/x/unionWith.min.js +1 -1
- package/dist/x/unionWith.mjs +39 -39
- package/dist/x/uniq.es.js +1 -1
- package/dist/x/uniq.es.min.js +1 -1
- package/dist/x/uniq.js +1 -1
- package/dist/x/uniq.min.js +1 -1
- package/dist/x/uniq.mjs +1 -1
- package/dist/x/unless.es.js +1 -1
- package/dist/x/unless.es.min.js +1 -1
- package/dist/x/unless.js +1 -1
- package/dist/x/unless.min.js +1 -1
- package/dist/x/unless.mjs +1 -1
- package/dist/x/values.es.js +1 -1
- package/dist/x/values.es.min.js +1 -1
- package/dist/x/values.js +1 -1
- package/dist/x/values.min.js +1 -1
- package/dist/x/values.mjs +1 -1
- package/dist/x/when.es.js +1 -1
- package/dist/x/when.es.min.js +1 -1
- package/dist/x/when.js +1 -1
- package/dist/x/when.min.js +1 -1
- package/dist/x/when.mjs +1 -1
- package/eq.js +32 -10
- package/es.js +218 -216
- package/every.d.ts +1 -1
- package/every.js +5 -3
- package/filter.d.ts +3 -3
- package/filter.js +15 -15
- package/flatMap.d.ts +9 -9
- package/flatMap.js +13 -11
- package/forEach.d.ts +1 -1
- package/forEach.js +19 -15
- package/gt.js +30 -13
- package/gte.js +31 -12
- package/index.js +218 -216
- package/lt.js +28 -9
- package/lte.js +34 -15
- package/map.d.ts +3 -3
- package/map.js +32 -32
- package/monad/Mux.benchmark.js +1 -1
- package/monad/Mux.js +6 -6
- package/monad/Struct.js +2 -2
- package/not.js +23 -8
- package/omit.js +2 -3
- package/or.js +30 -14
- package/package.json +1 -1
- package/pick.js +2 -3
- package/pipe.js +7 -15
- package/reduce.d.ts +7 -7
- package/reduce.js +19 -24
- package/some.d.ts +1 -1
- package/some.js +5 -3
- package/switchCase.d.ts +1 -1
- package/switchCase.js +13 -12
- package/tap.js +20 -4
- package/thunkify.js +2 -0
- package/transform.d.ts +1 -1
- package/transform.js +9 -23
- package/tryCatch.js +41 -8
- package/x/README.md +8 -8
- package/x/append.d.ts +2 -2
- package/x/append.js +8 -8
- package/x/defaultsDeep.js +94 -57
- package/x/defaultsDeep.test.js +24 -1
- package/x/differenceWith.js +13 -13
- package/x/find.d.ts +1 -1
- package/x/find.js +1 -1
- package/x/find.test.js +2 -2
- package/x/findIndex.test.js +1 -1
- package/x/first.d.ts +1 -1
- package/x/first.js +1 -1
- package/x/first.test.js +1 -1
- package/x/groupBy.d.ts +1 -1
- package/x/groupBy.js +13 -13
- package/x/last.d.ts +1 -1
- package/x/last.js +1 -1
- package/x/last.test.js +1 -1
- package/x/maxBy.d.ts +7 -7
- package/x/maxBy.js +13 -13
- package/x/maxBy.test.js +5 -5
- package/x/pluck.test.js +1 -1
- package/x/prepend.d.ts +2 -2
- package/x/prepend.js +8 -8
- package/x/size.d.ts +1 -1
- package/x/size.js +1 -1
- package/x/unionWith.js +11 -11
- package/x/unionWith.test.js +5 -5
package/README.md
CHANGED
|
@@ -26,7 +26,9 @@ pipe(numbers, [
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
# Installation
|
|
29
|
-
[Core build](https://unpkg.com/rubico/index.js) ([~
|
|
29
|
+
[Core build](https://unpkg.com/rubico/index.js) ([~7.7 kB minified and gzipped](https://unpkg.com/rubico/dist/rubico.min.js))
|
|
30
|
+
|
|
31
|
+
[Transducer module](https://unpkg.com/rubico/dist/Transducer.js) ([~1.5kb minified and gzipped](https://unpkg.com/rubico/dist/Transducer.min.js))
|
|
30
32
|
|
|
31
33
|
with `npm`
|
|
32
34
|
```bash
|
|
@@ -86,7 +88,7 @@ When you import this library, you obtain the freedom that comes from having thos
|
|
|
86
88
|
|
|
87
89
|
# Introduction
|
|
88
90
|
|
|
89
|
-
rubico is a library for
|
|
91
|
+
rubico is a library for [A]synchronous Functional Programming in JavaScript. The library supports a simple and composable functional style in asynchronous environments.
|
|
90
92
|
|
|
91
93
|
```javascript
|
|
92
94
|
const {
|
|
@@ -119,7 +121,7 @@ const {
|
|
|
119
121
|
} = rubico
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
With
|
|
124
|
+
With [A]synchronous Functional Programming, any function may be asynchronous and return a promise. All promises are resolved for their values before continuing with the operation.
|
|
123
125
|
|
|
124
126
|
```javascript [playground]
|
|
125
127
|
const helloPromise = Promise.resolve('hello')
|
|
@@ -133,7 +135,7 @@ pipe(helloPromise, [ // helloPromise is resolved for 'hello'
|
|
|
133
135
|
])
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
All rubico operators support both
|
|
138
|
+
All rubico operators support both eager and lazy APIs. The eager API takes all required arguments and executes at once, while the lazy API takes only the setup arguments and returns a function that executes later. This dual API supports a natural and composable code style.
|
|
137
139
|
|
|
138
140
|
```javascript [playground]
|
|
139
141
|
const myObj = { a: 1, b: 2, c: 3 }
|
|
@@ -203,7 +205,7 @@ pipe(todoIDs, [
|
|
|
203
205
|
])
|
|
204
206
|
```
|
|
205
207
|
|
|
206
|
-
rubico offers transducers
|
|
208
|
+
rubico offers transducers through its `Transducer` module. You can consume these transducers with rubico's `transform` and `compose` operators. You can use `compose` to chain a left-to-right composition of transducers.
|
|
207
209
|
|
|
208
210
|
```javascript [playground]
|
|
209
211
|
const isOdd = number => number % 2 == 1
|
|
@@ -219,18 +221,18 @@ const generateNumbers = function* () {
|
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
pipe(generateNumbers(), [
|
|
222
|
-
transform(compose(
|
|
224
|
+
transform(compose(
|
|
223
225
|
Transducer.filter(isOdd),
|
|
224
226
|
Transducer.map(asyncSquare),
|
|
225
|
-
|
|
227
|
+
), []),
|
|
226
228
|
console.log, // [1, 9, 25]
|
|
227
229
|
])
|
|
228
230
|
```
|
|
229
231
|
|
|
230
|
-
For advanced asynchronous use cases, some of the operators have property functions that have
|
|
231
|
-
* `map` -
|
|
232
|
-
* `map.pool` -
|
|
233
|
-
* `map.series` -
|
|
232
|
+
For advanced asynchronous use cases, some of the rubico operators have property functions that have various asynchronous behavior, e.g.
|
|
233
|
+
* `map` - applies a mapper function concurrently
|
|
234
|
+
* `map.pool` - applies a mapper function concurrently with a concurrency limit
|
|
235
|
+
* `map.series` - applies a mapper function serially
|
|
234
236
|
|
|
235
237
|
For more functions beyond the core operators, please visit `rubico/x`. You can find the full documentation at [rubico.land/docs](https://rubico.land/docs).
|
|
236
238
|
|
|
@@ -241,7 +243,7 @@ npm run bench
|
|
|
241
243
|
```
|
|
242
244
|
|
|
243
245
|
# Contributing
|
|
244
|
-
Your feedback and contributions are welcome. If you have a suggestion, please raise an issue. Prior to that, please search through the issues first in case your suggestion has been made already. If you decide to work on an issue,
|
|
246
|
+
Your feedback and contributions are welcome. If you have a suggestion, please raise an issue. Prior to that, please search through the issues first in case your suggestion has been made already. If you decide to work on an issue, please create a pull request.
|
|
245
247
|
|
|
246
248
|
Pull requests should provide some basic context and link the relevant issue. Here is an [example pull request](https://github.com/a-synchronous/rubico/pull/12). If you are interested in contributing, the [help wanted](https://github.com/a-synchronous/rubico/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) tag is a good place to start.
|
|
247
249
|
|
|
@@ -260,11 +262,6 @@ rubico is [MIT Licensed](https://github.com/a-synchronous/rubico/blob/master/LIC
|
|
|
260
262
|
# Awesome Resources
|
|
261
263
|
[rubico simplifies asynchronous code](https://dev.to/richytong/rubico-a-synchrnous-functional-syntax-motivation-20hf)
|
|
262
264
|
<br>
|
|
263
|
-
[Practical Functional Programming in JavaScript - Side Effects and Purity](https://dev.to/richytong/practical-functional-programming-in-javascript-side-effects-and-purity-revised-420h)
|
|
264
|
-
<br>
|
|
265
|
-
[Practical Functional Programming in JavaScript - Techniques for Composing Data](https://dev.to/richytong/practical-functional-programming-in-javascript-techniques-for-composing-data-c39)
|
|
266
|
-
<br>
|
|
267
|
-
[Practical Functional Programming in JavaScript - Error Handling](https://dev.to/richytong/practical-functional-programming-in-javascript-error-handling-8g5)
|
|
268
265
|
|
|
269
266
|
# Blog
|
|
270
267
|
Check out the rubico blog at [https://rubico.land/blog](https://rubico.land/blog)
|
package/Transducer.d.ts
CHANGED
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* @description
|
|
19
|
-
* Creates a mapping transducer.
|
|
19
|
+
* Creates a mapping transducer. Elements in the final reducing operation are transformed by the mapper function. It is possible to use an asynchronous mapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
20
20
|
*
|
|
21
21
|
* ```javascript [playground]
|
|
22
22
|
* const square = number => number ** 2
|
|
23
23
|
*
|
|
24
|
-
* const concat = (array,
|
|
24
|
+
* const concat = (array, element) => array.concat(element)
|
|
25
25
|
*
|
|
26
26
|
* const mapSquare = Transducer.map(square)
|
|
27
27
|
* // mapSquare is a transducer
|
|
@@ -66,12 +66,12 @@ export function map(mapper: any): (arg0: any) => any;
|
|
|
66
66
|
* ```
|
|
67
67
|
*
|
|
68
68
|
* @description
|
|
69
|
-
* Creates a filtering transducer. A filtering reducer skips
|
|
69
|
+
* Creates a filtering transducer. A filtering reducer skips elements of reducing operation if they test falsy by the predicate. It is possible to use an asynchronous predicate, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
70
70
|
*
|
|
71
71
|
* ```javascript [playground]
|
|
72
72
|
* const isOdd = number => number % 2 == 1
|
|
73
73
|
*
|
|
74
|
-
* const concat = (array,
|
|
74
|
+
* const concat = (array, element) => array.concat(element)
|
|
75
75
|
*
|
|
76
76
|
* const concatOddNumbers = filter(isOdd)(concat)
|
|
77
77
|
*
|
|
@@ -99,7 +99,7 @@ export function filter(predicate: any): (arg0: any) => any;
|
|
|
99
99
|
* ```
|
|
100
100
|
*
|
|
101
101
|
* @description
|
|
102
|
-
* Creates a flatMapping transducer. A flatMapping transducer applies the flatMapping function to each
|
|
102
|
+
* Creates a flatMapping transducer. A flatMapping transducer applies the flatMapping function to each element of the reducing operation, concatenating the results of the flatMapper execution into the final result. It is possible to use an asynchronous flatMapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
103
103
|
*
|
|
104
104
|
* ```javascript [playground]
|
|
105
105
|
* const powers = number => [number, number ** 2, number ** 3]
|
|
@@ -132,7 +132,7 @@ export function flatMap(flatMapper: any): (arg0: any) => any;
|
|
|
132
132
|
* ```
|
|
133
133
|
*
|
|
134
134
|
* @description
|
|
135
|
-
* Creates an effectful pasthrough transducer. The effectful passthrough transducer applies the effectful function to each
|
|
135
|
+
* Creates an effectful pasthrough transducer. The effectful passthrough transducer applies the effectful function to each element of the reducing operation, leaving the reducing operation unchanged. It is possible to use an asynchronous effectful function, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
136
136
|
*
|
|
137
137
|
* ```javascript [playground]
|
|
138
138
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -161,7 +161,7 @@ export function forEach(func: any): (arg0: any) => any;
|
|
|
161
161
|
* ```
|
|
162
162
|
*
|
|
163
163
|
* @description
|
|
164
|
-
* Creates a pasthrough transducer. The passthrough transducer passes each
|
|
164
|
+
* Creates a pasthrough transducer. The passthrough transducer passes each element of the reducing operation through, leaving the reducing operation unchanged.
|
|
165
165
|
*
|
|
166
166
|
* ```javascript [playground]
|
|
167
167
|
* const createAsyncNumbers = async function* () {
|
|
@@ -184,7 +184,7 @@ export function passthrough(reducer: any): any;
|
|
|
184
184
|
* ```coffeescript [specscript]
|
|
185
185
|
* type Reducer = (
|
|
186
186
|
* accumulator any,
|
|
187
|
-
*
|
|
187
|
+
* element any,
|
|
188
188
|
* indexOrKey? number|string,
|
|
189
189
|
* collection? Foldable,
|
|
190
190
|
* )=>(nextAccumulator Promise|any)
|
|
@@ -193,12 +193,12 @@ export function passthrough(reducer: any): any;
|
|
|
193
193
|
*
|
|
194
194
|
* Transducer.tryCatch(
|
|
195
195
|
* transducerTryer Transducer,
|
|
196
|
-
* catcher (error Error,
|
|
196
|
+
* catcher (error Error, element any)=>Promise|any,
|
|
197
197
|
* ) -> tryCatchTransducer Transducer
|
|
198
198
|
* ```
|
|
199
199
|
*
|
|
200
200
|
* @description
|
|
201
|
-
* Creates an error handling transducer. The error handling transducer wraps a transducer and catches any errors thrown by the transducer with the catcher function. The catcher function is provided the error as well as the original
|
|
201
|
+
* Creates an error handling transducer. The error handling transducer wraps a transducer and catches any errors thrown by the transducer with the catcher function. The catcher function is provided the error as well as the original element (before any processing by the transducer) for which the error was thrown. It is possible for either the transducer or the catcher to be asynchronous, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
202
202
|
*
|
|
203
203
|
* ```javascript [playground]
|
|
204
204
|
* const db = new Map()
|
package/Transducer.js
CHANGED
|
@@ -21,23 +21,22 @@ const Transducer = {}
|
|
|
21
21
|
*
|
|
22
22
|
* @synopsis
|
|
23
23
|
* ```coffeescript [specscript]
|
|
24
|
-
* type
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* )=>(nextAccumulator Promise|any)
|
|
24
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
25
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
26
|
+
* type UnarySyncOrAsyncMapper = (element any)=>(resultElement Promise|any)
|
|
28
27
|
*
|
|
29
|
-
*
|
|
28
|
+
* mapper UnarySyncOrAsyncMapper
|
|
30
29
|
*
|
|
31
|
-
* Transducer.map(
|
|
30
|
+
* Transducer.map(mapper) -> mappingTransducer Transducer
|
|
32
31
|
* ```
|
|
33
32
|
*
|
|
34
33
|
* @description
|
|
35
|
-
* Creates a mapping transducer.
|
|
34
|
+
* Creates a mapping transducer. Elements of the transducer's reducing operation are transformed by the mapper function. It is possible to use an asynchronous mapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
36
35
|
*
|
|
37
36
|
* ```javascript [playground]
|
|
38
37
|
* const square = number => number ** 2
|
|
39
38
|
*
|
|
40
|
-
* const concat = (array,
|
|
39
|
+
* const concat = (array, element) => array.concat(element)
|
|
41
40
|
*
|
|
42
41
|
* const mapSquare = Transducer.map(square)
|
|
43
42
|
* // mapSquare is a transducer
|
|
@@ -81,29 +80,32 @@ Transducer.map = function transducerMap(mapper) {
|
|
|
81
80
|
*
|
|
82
81
|
* @synopsis
|
|
83
82
|
* ```coffeescript [specscript]
|
|
84
|
-
* type
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* )=>(nextAccumulator Promise|any)
|
|
83
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
84
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
85
|
+
* type UnarySyncOrAsyncPredicate = any=>Promise|boolean|any
|
|
88
86
|
*
|
|
89
|
-
*
|
|
87
|
+
* predicate UnarySyncOrAsyncPredicate
|
|
90
88
|
*
|
|
91
|
-
* Transducer.filter(predicate
|
|
89
|
+
* Transducer.filter(predicate) -> filteringTransducer Transducer
|
|
92
90
|
* ```
|
|
93
91
|
*
|
|
94
92
|
* @description
|
|
95
|
-
* Creates a filtering transducer. A filtering
|
|
93
|
+
* Creates a filtering transducer. A filtering transducer filters out elements of its reducing operation if they test false by the predicate. It is possible to use an asynchronous predicate, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
96
94
|
*
|
|
97
95
|
* ```javascript [playground]
|
|
98
96
|
* const isOdd = number => number % 2 == 1
|
|
99
97
|
*
|
|
100
|
-
* const concat = (array,
|
|
98
|
+
* const concat = (array, element) => array.concat(element)
|
|
101
99
|
*
|
|
102
|
-
* const concatOddNumbers = filter(isOdd)(concat)
|
|
100
|
+
* const concatOddNumbers = Transducer.filter(isOdd)(concat)
|
|
103
101
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
102
|
+
* const array = [1, 2, 3, 4, 5]
|
|
103
|
+
*
|
|
104
|
+
* const oddNumbers1 = array.reduce(concatOddNumbers, [])
|
|
105
|
+
* console.log(oddNumbers1) // [1, 3, 5]
|
|
106
|
+
*
|
|
107
|
+
* const oddNumbers2 = transform(array, Transducer.filter(isOdd), [])
|
|
108
|
+
* console.log(oddNumbers2) // [1, 3, 5]
|
|
107
109
|
* ```
|
|
108
110
|
*
|
|
109
111
|
* Read more on [transducers](/blog/transducers-crash-course-rubico-v2).
|
|
@@ -126,18 +128,18 @@ Transducer.filter = function transducerFilter(predicate) {
|
|
|
126
128
|
*
|
|
127
129
|
* @synopsis
|
|
128
130
|
* ```coffeescript [specscript]
|
|
129
|
-
* type
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* )=>(
|
|
131
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
132
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
133
|
+
* type Monad = Array|String|Set|Generator|AsyncGenerator|{ flatMap: string }|{ chain: string }|Object
|
|
134
|
+
* type UnarySyncOrAsyncFlatMapper = (element any)=>(monad Promise|Monad|any)
|
|
133
135
|
*
|
|
134
|
-
*
|
|
136
|
+
* flatMapper UnarySyncOrAsyncFlatMapper
|
|
135
137
|
*
|
|
136
138
|
* Transducer.flatMap(flatMapper) -> flatMappingTransducer Transducer
|
|
137
139
|
* ```
|
|
138
140
|
*
|
|
139
141
|
* @description
|
|
140
|
-
* Creates a flatMapping transducer. A flatMapping transducer applies the
|
|
142
|
+
* Creates a flatMapping transducer. A flatMapping transducer applies the flatMapper function to each element of its reducing operation, concatenating the results of the flatMapper execution onto the accumulator. It is possible to use an asynchronous flatMapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
141
143
|
*
|
|
142
144
|
* ```javascript [playground]
|
|
143
145
|
* const powers = number => [number, number ** 2, number ** 3]
|
|
@@ -169,25 +171,24 @@ Transducer.flatMap = function transducerFlatMap(flatMapper) {
|
|
|
169
171
|
*
|
|
170
172
|
* @synopsis
|
|
171
173
|
* ```coffeescript [specscript]
|
|
172
|
-
* type
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* )=>(nextAccumulator Promise|any)
|
|
174
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
175
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
176
|
+
* type UnarySyncOrAsyncCallback = (element any)=>Promise|undefined
|
|
176
177
|
*
|
|
177
|
-
*
|
|
178
|
+
* callback UnarySyncOrAsyncCallback
|
|
178
179
|
*
|
|
179
|
-
* Transducer.forEach(
|
|
180
|
+
* Transducer.forEach(callback) -> forEachTransducer Transducer
|
|
180
181
|
* ```
|
|
181
182
|
*
|
|
182
183
|
* @description
|
|
183
|
-
*
|
|
184
|
+
* Executes a callback function for each element of a reducing operation, leaving the reducing operation unmodified. It is possible to use an asynchronous callback function, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
184
185
|
*
|
|
185
186
|
* ```javascript [playground]
|
|
186
187
|
* const numbers = [1, 2, 3, 4, 5]
|
|
187
|
-
* transform(numbers, compose(
|
|
188
|
+
* transform(numbers, compose(
|
|
188
189
|
* Transducer.map(number => number ** 2),
|
|
189
190
|
* Transducer.forEach(console.log), // 1 4 9 16 25
|
|
190
|
-
*
|
|
191
|
+
* ), null)
|
|
191
192
|
* ```
|
|
192
193
|
*
|
|
193
194
|
* Read more on [transducers](/blog/transducers-crash-course-rubico-v2).
|
|
@@ -210,18 +211,14 @@ Transducer.forEach = function transducerForEach(func) {
|
|
|
210
211
|
*
|
|
211
212
|
* @synopsis
|
|
212
213
|
* ```coffeescript [specscript]
|
|
213
|
-
* type
|
|
214
|
-
*
|
|
215
|
-
* value any,
|
|
216
|
-
* )=>(nextAccumulator Promise|any)
|
|
214
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
215
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
217
216
|
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* Transducer.passthrough(func function) -> passthroughTransducer Transducer
|
|
217
|
+
* Transducer.passthrough Transducer
|
|
221
218
|
* ```
|
|
222
219
|
*
|
|
223
220
|
* @description
|
|
224
|
-
* Creates a pasthrough transducer. The passthrough transducer passes each
|
|
221
|
+
* Creates a pasthrough transducer. The passthrough transducer simply passes each element of the reducing operation through to the next downstream operation, leaving the reducing operation unmodified.
|
|
225
222
|
*
|
|
226
223
|
* ```javascript [playground]
|
|
227
224
|
* const createAsyncNumbers = async function* () {
|
|
@@ -256,21 +253,17 @@ Transducer.passthrough = function transducerPassthrough(reducer) {
|
|
|
256
253
|
*
|
|
257
254
|
* @synopsis
|
|
258
255
|
* ```coffeescript [specscript]
|
|
259
|
-
* type
|
|
260
|
-
*
|
|
261
|
-
* item any,
|
|
262
|
-
* )=>(nextAccumulator Promise|any)
|
|
256
|
+
* type SyncOrAsyncReducer = (accumulator any, value any)=>(nextAccumulator Promise|any)
|
|
257
|
+
* type Transducer = SyncOrAsyncReducer=>SyncOrAsyncReducer
|
|
263
258
|
*
|
|
264
|
-
*
|
|
259
|
+
* transducerTryer Transducer
|
|
260
|
+
* catcher (error Error, element any)=>Promise|any
|
|
265
261
|
*
|
|
266
|
-
* Transducer.tryCatch(
|
|
267
|
-
* transducerTryer Transducer,
|
|
268
|
-
* catcher (error Error, item any)=>Promise|any,
|
|
269
|
-
* ) -> tryCatchTransducer Transducer
|
|
262
|
+
* Transducer.tryCatch(transducerTryer, catcher) -> tryCatchTransducer Transducer
|
|
270
263
|
* ```
|
|
271
264
|
*
|
|
272
265
|
* @description
|
|
273
|
-
* Creates an error handling transducer. The error handling transducer wraps a transducer and catches any errors thrown by the transducer with the catcher function. The catcher function is provided the error as well as the
|
|
266
|
+
* Creates an error handling transducer. The error handling transducer wraps a transducer and catches any errors thrown by the transducer with the catcher function. The catcher function is provided the error as well as the element for which the error was thrown. It is possible for either the transducer or the catcher to be asynchronous, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
|
|
274
267
|
*
|
|
275
268
|
* ```javascript [playground]
|
|
276
269
|
* const db = new Map()
|
|
@@ -281,22 +274,25 @@ Transducer.passthrough = function transducerPassthrough(reducer) {
|
|
|
281
274
|
*
|
|
282
275
|
* const userIds = ['a', 'b', 'c', 'd', 'e']
|
|
283
276
|
*
|
|
284
|
-
* transform(userIds, Transducer.tryCatch(
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
277
|
+
* transform(userIds, Transducer.tryCatch(
|
|
278
|
+
* compose(
|
|
279
|
+
* Transducer.map(async userId => {
|
|
280
|
+
* if (db.has(userId)) {
|
|
281
|
+
* return db.get(userId)
|
|
282
|
+
* }
|
|
283
|
+
* throw new Error(`user ${userId} not found`)
|
|
284
|
+
* }),
|
|
285
|
+
*
|
|
286
|
+
* Transducer.forEach(user => {
|
|
287
|
+
* console.log('Found', user.name)
|
|
288
|
+
* })
|
|
289
|
+
* ),
|
|
290
|
+
* (error, userId) => {
|
|
291
|
+
* console.error(error)
|
|
292
|
+
* console.log('userId in catcher:', userId)
|
|
293
|
+
* // original userId for which the error was thrown is provided
|
|
294
|
+
* }
|
|
295
|
+
* ), null)
|
|
300
296
|
* ```
|
|
301
297
|
*
|
|
302
298
|
* Read more on [transducers](/blog/transducers-crash-course-rubico-v2).
|
package/__.js
CHANGED
|
@@ -33,7 +33,7 @@ const FlatMappingIterator = function (iterator, flatMapper) {
|
|
|
33
33
|
const monadAsArray = genericReduce(
|
|
34
34
|
flatMapper(iteration.value),
|
|
35
35
|
arrayPush,
|
|
36
|
-
[]) // this will always have at least one
|
|
36
|
+
[]) // this will always have at least one element
|
|
37
37
|
if (monadAsArray.length > 1) {
|
|
38
38
|
buffer = monadAsArray
|
|
39
39
|
bufferIndex = 1
|
|
@@ -14,7 +14,7 @@ export = MappingIterator;
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @description
|
|
17
|
-
* Creates a mapping iterator, i.e. an iterator that applies a mapper to each
|
|
17
|
+
* Creates a mapping iterator, i.e. an iterator that applies a mapper to each element of a source iterator.
|
|
18
18
|
*
|
|
19
19
|
* Note: consuming the mapping iterator also consumes the source iterator.
|
|
20
20
|
*/
|
|
@@ -15,7 +15,7 @@ const symbolIterator = require('./symbolIterator')
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @description
|
|
18
|
-
* Creates a mapping iterator, i.e. an iterator that applies a mapper to each
|
|
18
|
+
* Creates a mapping iterator, i.e. an iterator that applies a mapper to each element of a source iterator.
|
|
19
19
|
*
|
|
20
20
|
* Note: consuming the mapping iterator also consumes the source iterator.
|
|
21
21
|
*/
|
package/_internal/arrayFilter.js
CHANGED
|
@@ -25,15 +25,15 @@ const arrayFilter = function (array, predicate) {
|
|
|
25
25
|
let index = -1,
|
|
26
26
|
resultIndex = -1
|
|
27
27
|
while (++index < arrayLength) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (isPromise(
|
|
28
|
+
const element = array[index],
|
|
29
|
+
shouldIncludeElement = predicate(element, index, array)
|
|
30
|
+
if (isPromise(shouldIncludeElement)) {
|
|
31
31
|
return promiseAll(
|
|
32
|
-
arrayExtendMap([
|
|
32
|
+
arrayExtendMap([shouldIncludeElement], array, predicate, index)
|
|
33
33
|
).then(curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
36
|
-
result[++resultIndex] =
|
|
35
|
+
if (shouldIncludeElement) {
|
|
36
|
+
result[++resultIndex] = element
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
return result
|
|
@@ -24,17 +24,17 @@ const arrayFilterIndexes = function (predicate, array) {
|
|
|
24
24
|
let index = -1,
|
|
25
25
|
resultIndex = -1
|
|
26
26
|
while (++index < arrayLength) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (isPromise(
|
|
30
|
-
const predicationPromises = [
|
|
27
|
+
const element = array[index],
|
|
28
|
+
shouldIncludeElement = predicate(index)
|
|
29
|
+
if (isPromise(shouldIncludeElement)) {
|
|
30
|
+
const predicationPromises = [shouldIncludeElement]
|
|
31
31
|
return promiseAll(
|
|
32
32
|
arrayExtendMapIndexes(
|
|
33
|
-
[
|
|
33
|
+
[shouldIncludeElement], array, predicate, index)).then(
|
|
34
34
|
curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
37
|
-
result[++resultIndex] =
|
|
36
|
+
if (shouldIncludeElement) {
|
|
37
|
+
result[++resultIndex] = element
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return result
|
|
@@ -27,16 +27,16 @@ const arrayFilterWithIndex = function (array, predicate) {
|
|
|
27
27
|
let index = -1,
|
|
28
28
|
resultIndex = -1
|
|
29
29
|
while (++index < arrayLength) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
if (isPromise(
|
|
30
|
+
const element = array[index],
|
|
31
|
+
shouldIncludeElement = predicate(element, index, array)
|
|
32
|
+
if (isPromise(shouldIncludeElement)) {
|
|
33
33
|
return promiseAll(
|
|
34
34
|
arrayExtendMapWithIndex(
|
|
35
|
-
[
|
|
35
|
+
[shouldIncludeElement], array, predicate, index)).then(
|
|
36
36
|
curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
39
|
-
result[++resultIndex] =
|
|
38
|
+
if (shouldIncludeElement) {
|
|
39
|
+
result[++resultIndex] = element
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return result
|
package/_internal/arrayFind.js
CHANGED
|
@@ -21,13 +21,13 @@ const always = require('./always')
|
|
|
21
21
|
const arrayFindAsync = async function (array, predicate, index) {
|
|
22
22
|
const length = array.length
|
|
23
23
|
while (++index < length) {
|
|
24
|
-
const
|
|
25
|
-
let predication = predicate(
|
|
24
|
+
const element = array[index]
|
|
25
|
+
let predication = predicate(element)
|
|
26
26
|
if (isPromise(predication)) {
|
|
27
27
|
predication = await predication
|
|
28
28
|
}
|
|
29
29
|
if (predication) {
|
|
30
|
-
return
|
|
30
|
+
return element
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return undefined
|
|
@@ -50,16 +50,16 @@ const arrayFind = function (array, predicate) {
|
|
|
50
50
|
const length = array.length
|
|
51
51
|
let index = -1
|
|
52
52
|
while (++index < length) {
|
|
53
|
-
const
|
|
54
|
-
predication = predicate(
|
|
53
|
+
const element = array[index],
|
|
54
|
+
predication = predicate(element)
|
|
55
55
|
if (isPromise(predication)) {
|
|
56
56
|
return predication.then(curry3(
|
|
57
57
|
thunkConditional,
|
|
58
58
|
__,
|
|
59
|
-
always(
|
|
59
|
+
always(element),
|
|
60
60
|
thunkify3(arrayFindAsync, array, predicate, index)))
|
|
61
61
|
} else if (predication) {
|
|
62
|
-
return
|
|
62
|
+
return element
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
return undefined
|
|
@@ -37,44 +37,44 @@ const arrayFlatten = function (array) {
|
|
|
37
37
|
let index = -1
|
|
38
38
|
|
|
39
39
|
while (++index < length) {
|
|
40
|
-
const
|
|
41
|
-
if (isArray(
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
while (++
|
|
45
|
-
result.push(
|
|
40
|
+
const element = array[index]
|
|
41
|
+
if (isArray(element)) {
|
|
42
|
+
const elementLength = element.length
|
|
43
|
+
let elementIndex = -1
|
|
44
|
+
while (++elementIndex < elementLength) {
|
|
45
|
+
result.push(element[elementIndex])
|
|
46
46
|
}
|
|
47
|
-
} else if (
|
|
48
|
-
result.push(
|
|
49
|
-
} else if (typeof
|
|
50
|
-
promises.push(
|
|
51
|
-
} else if (typeof
|
|
52
|
-
for (const
|
|
53
|
-
result.push(
|
|
47
|
+
} else if (element == null) {
|
|
48
|
+
result.push(element)
|
|
49
|
+
} else if (typeof element.then == 'function') {
|
|
50
|
+
promises.push(element.then(curry2(arrayPush, result, __)))
|
|
51
|
+
} else if (typeof element[symbolIterator] == 'function') {
|
|
52
|
+
for (const subElement of element) {
|
|
53
|
+
result.push(subElement)
|
|
54
54
|
}
|
|
55
|
-
} else if (typeof
|
|
55
|
+
} else if (typeof element[symbolAsyncIterator] == 'function') {
|
|
56
56
|
promises.push(asyncIteratorForEach(
|
|
57
|
-
|
|
58
|
-
} else if (typeof
|
|
59
|
-
const monadValue =
|
|
57
|
+
element[symbolAsyncIterator](), curry2(arrayPush, result, __)))
|
|
58
|
+
} else if (typeof element.chain == 'function') {
|
|
59
|
+
const monadValue = element.chain(identity)
|
|
60
60
|
isPromise(monadValue)
|
|
61
61
|
? promises.push(monadValue.then(curry2(arrayPush, result, __)))
|
|
62
62
|
: result.push(monadValue)
|
|
63
|
-
} else if (typeof
|
|
64
|
-
const monadValue =
|
|
63
|
+
} else if (typeof element.flatMap == 'function') {
|
|
64
|
+
const monadValue = element.flatMap(identity)
|
|
65
65
|
isPromise(monadValue)
|
|
66
66
|
? promises.push(monadValue.then(curry2(arrayPush, result, __)))
|
|
67
67
|
: result.push(monadValue)
|
|
68
|
-
} else if (typeof
|
|
69
|
-
const folded =
|
|
68
|
+
} else if (typeof element.reduce == 'function') {
|
|
69
|
+
const folded = element.reduce(funcConcatSync(
|
|
70
70
|
getArg1, curry2(arrayPush, result, __)), null)
|
|
71
71
|
isPromise(folded) && promises.push(folded)
|
|
72
|
-
} else if (
|
|
73
|
-
for (const key in
|
|
74
|
-
result.push(
|
|
72
|
+
} else if (element.constructor == Object) {
|
|
73
|
+
for (const key in element) {
|
|
74
|
+
result.push(element[key])
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
|
-
result.push(
|
|
77
|
+
result.push(element)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
return promises.length == 0
|
|
@@ -12,7 +12,7 @@ export = arrayForEach;
|
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
14
|
* @description
|
|
15
|
-
* Call a callback for each
|
|
15
|
+
* Call a callback for each element of an iterator. Return a promise if any executions are asynchronous.
|
|
16
16
|
*
|
|
17
17
|
* Note: iterator is consumed
|
|
18
18
|
*/
|
|
@@ -15,7 +15,7 @@ const always = require('./always')
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @description
|
|
18
|
-
* Call a callback for each
|
|
18
|
+
* Call a callback for each element of an iterator. Return a promise if any executions are asynchronous.
|
|
19
19
|
*
|
|
20
20
|
* Note: iterator is consumed
|
|
21
21
|
*/
|