rubico 1.9.7 → 2.0.0
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/.eslintignore +5 -0
- package/.eslintrc.js +3 -2
- package/.github/workflows/nodejs.yml +1 -1
- package/AggregateReducer.js +19 -0
- package/AggregateReducer.test.js +82 -0
- package/CHANGELOG.md +22 -1
- package/Transducer.js +75 -26
- package/Transducer.test.js +117 -0
- package/_internal/ComparisonOperator.js +68 -0
- package/_internal/File.js +41 -0
- package/_internal/FlatMappingAsyncIterator.js +4 -4
- package/_internal/FlatMappingIterator.js +1 -1
- package/_internal/TimeInLoopSuite.js +138 -0
- package/_internal/areAnyValuesPromises.js +23 -0
- package/_internal/{arrayAll.js → arrayEvery.js} +4 -4
- package/_internal/arrayExtend.js +3 -2
- package/_internal/arrayFilter.js +3 -4
- package/_internal/{arrayAny.js → arraySome.js} +8 -8
- package/_internal/{asyncIteratorAll.js → asyncIteratorEvery.js} +4 -4
- package/_internal/{asyncIteratorAny.js → asyncIteratorSome.js} +4 -4
- package/_internal/curry4.test.js +25 -0
- package/_internal/curry5.test.js +29 -0
- package/_internal/curryArgs2.js +43 -0
- package/_internal/curryArgs3.test.js +21 -0
- package/_internal/curryArgs4.js +65 -0
- package/_internal/curryArgs4.test.js +25 -0
- package/_internal/equals.js +13 -0
- package/_internal/findAllFilePaths.js +22 -0
- package/_internal/funcApply.js +2 -0
- package/_internal/funcCall.js +14 -0
- package/_internal/functionArrayAll.js +26 -0
- package/_internal/functionArrayAllSeries.js +55 -0
- package/_internal/functionObjectAll.js +32 -0
- package/_internal/genericReduce.js +4 -22
- package/_internal/genericTransform.js +15 -15
- package/_internal/improvedGenericTransform.js +93 -0
- package/_internal/{iteratorAll.js → iteratorEvery.js} +4 -4
- package/_internal/{iteratorAny.js → iteratorSome.js} +6 -6
- package/_internal/leftResolverRightResolverCompare.js +19 -0
- package/_internal/leftResolverRightValueCompare.js +16 -0
- package/_internal/leftValueRightResolverCompare.js +16 -0
- package/_internal/objectReduce.js +0 -1
- package/_internal/pathResolve.js +6 -0
- package/_internal/{reducerAll.js → reducerEvery.js} +4 -4
- package/_internal/reducerFlatMap.js +4 -4
- package/_internal/reducerFlatten.js +1 -1
- package/_internal/{reducerAny.js → reducerSome.js} +4 -4
- package/_internal/timeInLoop.js +37 -0
- package/_internal/timeInLoop.test.js +18 -0
- package/_internal/timeInLoopAsync.js +35 -0
- package/_internal/timeInLoopAsync.test.js +22 -0
- package/all.js +106 -40
- package/and.js +54 -36
- package/archive/{FlatMappingIteratorCool.js → FlatMappingIterator-2020-09-28.js} +1 -1
- package/archive/_Promise-2023-05-29.js +93 -0
- package/archive/arrayMap2-2023-05-29.js +73 -0
- package/archive/benchmarks-v1.9.7/all.js +34 -0
- package/archive/benchmarks-v1.9.7/and.js +24 -0
- package/archive/benchmarks-v1.9.7/assign.js +174 -0
- package/archive/benchmarks-v1.9.7/curry.js +55 -0
- package/archive/benchmarks-v1.9.7/eq.js +25 -0
- package/archive/benchmarks-v1.9.7/filter.js +1322 -0
- package/archive/benchmarks-v1.9.7/flatMap.js +48 -0
- package/archive/benchmarks-v1.9.7/get.js +44 -0
- package/archive/benchmarks-v1.9.7/gt.js +25 -0
- package/archive/benchmarks-v1.9.7/gte.js +25 -0
- package/archive/benchmarks-v1.9.7/lt.js +25 -0
- package/archive/benchmarks-v1.9.7/lte.js +25 -0
- package/archive/benchmarks-v1.9.7/map.js +892 -0
- package/archive/benchmarks-v1.9.7/omit.js +28 -0
- package/archive/benchmarks-v1.9.7/or.js +51 -0
- package/archive/benchmarks-v1.9.7/pick.js +24 -0
- package/archive/benchmarks-v1.9.7/pipe.js +152 -0
- package/archive/benchmarks-v1.9.7/reduce.js +739 -0
- package/archive/benchmarks-v1.9.7/switchCase.js +256 -0
- package/archive/benchmarks-v1.9.7/tap.js +90 -0
- package/archive/benchmarks-v1.9.7/transform.js +218 -0
- package/archive/benchmarks-v1.9.7/tryCatch.js +108 -0
- package/assign.js +18 -8
- package/bench +65 -0
- package/benchmark-output/v1.9.7 +268 -0
- package/benchmarks/all.async.js +43 -0
- package/benchmarks/all.js +42 -33
- package/benchmarks/always.js +15 -0
- package/benchmarks/and.async.js +25 -0
- package/benchmarks/and.js +20 -19
- package/benchmarks/assign.async.js +27 -0
- package/benchmarks/assign.js +20 -167
- package/benchmarks/curry.js +34 -54
- package/benchmarks/eq.async.js +23 -0
- package/benchmarks/eq.js +17 -19
- package/benchmarks/every.async.js +19 -0
- package/benchmarks/every.js +19 -0
- package/benchmarks/filter.async.js +32 -0
- package/benchmarks/filter.js +27 -1311
- package/benchmarks/flatMap.async.js +26 -0
- package/benchmarks/flatMap.js +26 -36
- package/benchmarks/get.async.js +19 -0
- package/benchmarks/get.js +27 -32
- package/benchmarks/gt.async.js +23 -0
- package/benchmarks/gt.js +17 -19
- package/benchmarks/gte.async.js +23 -0
- package/benchmarks/gte.js +17 -19
- package/benchmarks/lt.async.js +23 -0
- package/benchmarks/lt.js +17 -19
- package/benchmarks/lte.async.js +23 -0
- package/benchmarks/lte.js +17 -19
- package/benchmarks/map.async.js +43 -0
- package/benchmarks/map.js +24 -876
- package/benchmarks/misc/Promise.js +26 -0
- package/benchmarks/misc/isPromise.js +30 -0
- package/benchmarks/misc/promiseAll.js +36 -0
- package/benchmarks/not.js +23 -0
- package/benchmarks/omit.js +30 -20
- package/benchmarks/or.async.js +25 -0
- package/benchmarks/or.js +23 -49
- package/benchmarks/pick.js +30 -16
- package/benchmarks/pipe.async.js +47 -0
- package/benchmarks/pipe.js +46 -151
- package/benchmarks/reduce.async.js +32 -0
- package/benchmarks/reduce.js +27 -728
- package/benchmarks/set.async.js +19 -0
- package/benchmarks/set.js +41 -0
- package/benchmarks/some.async.js +19 -0
- package/benchmarks/some.js +19 -0
- package/benchmarks/switchCase.async.js +27 -0
- package/benchmarks/switchCase.js +55 -256
- package/benchmarks/tap.js +10 -85
- package/benchmarks/thunkify.js +15 -0
- package/benchmarks/transform.async.js +27 -0
- package/benchmarks/transform.js +28 -206
- package/benchmarks/tryCatch.async.js +25 -0
- package/benchmarks/tryCatch.js +24 -100
- package/{distributor.js → build} +50 -50
- package/compose.js +46 -0
- package/dist/__.es.js +2 -2
- package/dist/__.es.min.js +2 -2
- package/dist/__.js +2 -2
- package/dist/__.min.js +2 -2
- package/dist/__.min.mjs +2 -2
- package/dist/__.mjs +2 -2
- package/dist/all.es.js +173 -92
- package/dist/all.es.min.js +3 -3
- package/dist/all.js +173 -92
- package/dist/all.min.js +3 -3
- package/dist/all.min.mjs +3 -3
- package/dist/all.mjs +173 -92
- package/dist/always.es.js +2 -2
- package/dist/always.es.min.js +2 -2
- package/dist/always.js +2 -2
- package/dist/always.min.js +2 -2
- package/dist/always.min.mjs +2 -2
- package/dist/always.mjs +2 -2
- package/dist/and.es.js +101 -32
- package/dist/and.es.min.js +3 -3
- package/dist/and.js +101 -32
- package/dist/and.min.js +3 -3
- package/dist/and.min.mjs +3 -3
- package/dist/and.mjs +101 -32
- package/dist/assign.es.js +37 -10
- package/dist/assign.es.min.js +3 -3
- package/dist/assign.js +37 -10
- package/dist/assign.min.js +3 -3
- package/dist/assign.min.mjs +3 -3
- package/dist/assign.mjs +37 -10
- package/dist/compose.es.js +71 -0
- package/dist/compose.es.min.js +7 -0
- package/dist/compose.js +78 -0
- package/dist/compose.min.js +8 -0
- package/dist/compose.min.mjs +7 -0
- package/dist/compose.mjs +71 -0
- package/dist/curry.es.js +2 -2
- package/dist/curry.es.min.js +2 -2
- package/dist/curry.js +2 -2
- package/dist/curry.min.js +2 -2
- package/dist/curry.min.mjs +2 -2
- package/dist/curry.mjs +2 -2
- package/dist/eq.es.js +172 -49
- package/dist/eq.es.min.js +3 -3
- package/dist/eq.js +172 -49
- package/dist/eq.min.js +3 -3
- package/dist/eq.min.mjs +3 -3
- package/dist/eq.mjs +172 -49
- package/dist/every.es.js +194 -0
- package/dist/every.es.min.js +7 -0
- package/dist/every.js +201 -0
- package/dist/every.min.js +8 -0
- package/dist/every.min.mjs +7 -0
- package/dist/every.mjs +194 -0
- package/dist/filter.es.js +14 -108
- package/dist/filter.es.min.js +3 -3
- package/dist/filter.js +14 -108
- package/dist/filter.min.js +3 -3
- package/dist/filter.min.mjs +3 -3
- package/dist/filter.mjs +14 -108
- package/dist/flatMap.es.js +27 -214
- package/dist/flatMap.es.min.js +3 -3
- package/dist/flatMap.js +27 -214
- package/dist/flatMap.min.js +3 -3
- package/dist/flatMap.min.mjs +3 -3
- package/dist/flatMap.mjs +27 -214
- package/dist/{x/forEach.es.js → forEach.es.js} +52 -70
- package/dist/forEach.es.min.js +7 -0
- package/dist/{x/forEach.js → forEach.js} +52 -70
- package/dist/forEach.min.js +8 -0
- package/dist/forEach.min.mjs +7 -0
- package/dist/{x/forEach.mjs → forEach.mjs} +52 -70
- package/dist/get.es.js +60 -5
- package/dist/get.es.min.js +3 -3
- package/dist/get.js +60 -5
- package/dist/get.min.js +3 -3
- package/dist/get.min.mjs +3 -3
- package/dist/get.mjs +60 -5
- package/dist/gt.es.js +171 -48
- package/dist/gt.es.min.js +3 -3
- package/dist/gt.js +171 -48
- package/dist/gt.min.js +3 -3
- package/dist/gt.min.mjs +3 -3
- package/dist/gt.mjs +171 -48
- package/dist/gte.es.js +171 -48
- package/dist/gte.es.min.js +3 -3
- package/dist/gte.js +171 -48
- package/dist/gte.min.js +3 -3
- package/dist/gte.min.mjs +3 -3
- package/dist/gte.mjs +171 -48
- package/dist/lt.es.js +171 -48
- package/dist/lt.es.min.js +3 -3
- package/dist/lt.js +171 -48
- package/dist/lt.min.js +3 -3
- package/dist/lt.min.mjs +3 -3
- package/dist/lt.mjs +171 -48
- package/dist/lte.es.js +171 -48
- package/dist/lte.es.min.js +3 -3
- package/dist/lte.js +171 -48
- package/dist/lte.min.js +3 -3
- package/dist/lte.min.mjs +3 -3
- package/dist/lte.mjs +171 -48
- package/dist/map.es.js +12 -101
- package/dist/map.es.min.js +3 -3
- package/dist/map.js +12 -101
- package/dist/map.min.js +3 -3
- package/dist/map.min.mjs +3 -3
- package/dist/map.mjs +12 -101
- package/dist/not.es.js +75 -14
- package/dist/not.es.min.js +3 -3
- package/dist/not.js +75 -14
- package/dist/not.min.js +3 -3
- package/dist/not.min.mjs +3 -3
- package/dist/not.mjs +75 -14
- package/dist/omit.es.js +7 -2
- package/dist/omit.es.min.js +3 -3
- package/dist/omit.js +7 -2
- package/dist/omit.min.js +3 -3
- package/dist/omit.min.mjs +3 -3
- package/dist/omit.mjs +7 -2
- package/dist/or.es.js +99 -31
- package/dist/or.es.min.js +3 -3
- package/dist/or.js +99 -31
- package/dist/or.min.js +3 -3
- package/dist/or.min.mjs +3 -3
- package/dist/or.mjs +99 -31
- package/dist/pick.es.js +8 -3
- package/dist/pick.es.min.js +3 -3
- package/dist/pick.js +8 -3
- package/dist/pick.min.js +3 -3
- package/dist/pick.min.mjs +3 -3
- package/dist/pick.mjs +8 -3
- package/dist/pipe.es.js +42 -46
- package/dist/pipe.es.min.js +3 -3
- package/dist/pipe.js +42 -46
- package/dist/pipe.min.js +3 -3
- package/dist/pipe.min.mjs +3 -3
- package/dist/pipe.mjs +42 -46
- package/dist/reduce.es.js +52 -94
- package/dist/reduce.es.min.js +3 -3
- package/dist/reduce.js +52 -94
- package/dist/reduce.min.js +3 -3
- package/dist/reduce.min.mjs +3 -3
- package/dist/reduce.mjs +52 -94
- package/dist/rubico.es.js +730 -869
- package/dist/rubico.es.min.js +3 -3
- package/dist/rubico.js +730 -869
- package/dist/rubico.min.js +3 -3
- package/dist/rubico.min.mjs +3 -3
- package/dist/rubico.mjs +730 -869
- package/dist/set.es.js +18 -3
- package/dist/set.es.min.js +3 -3
- package/dist/set.js +18 -3
- package/dist/set.min.js +3 -3
- package/dist/set.min.mjs +3 -3
- package/dist/set.mjs +18 -3
- package/dist/{any.js → some.es.js} +64 -54
- package/dist/some.es.min.js +7 -0
- package/dist/{any.mjs → some.js} +72 -48
- package/dist/some.min.js +8 -0
- package/dist/some.min.mjs +7 -0
- package/dist/{any.es.js → some.mjs} +65 -48
- package/dist/switchCase.es.js +55 -5
- package/dist/switchCase.es.min.js +3 -3
- package/dist/switchCase.js +55 -5
- package/dist/switchCase.min.js +3 -3
- package/dist/switchCase.min.mjs +3 -3
- package/dist/switchCase.mjs +55 -5
- package/dist/tap.es.js +2 -9
- package/dist/tap.es.min.js +3 -3
- package/dist/tap.js +2 -9
- package/dist/tap.min.js +3 -3
- package/dist/tap.min.mjs +3 -3
- package/dist/tap.mjs +2 -9
- package/dist/thunkify.es.js +45 -2
- package/dist/thunkify.es.min.js +3 -3
- package/dist/thunkify.js +45 -2
- package/dist/thunkify.min.js +3 -3
- package/dist/thunkify.min.mjs +3 -3
- package/dist/thunkify.mjs +45 -2
- package/dist/transform.es.js +35 -71
- package/dist/transform.es.min.js +3 -3
- package/dist/transform.js +35 -71
- package/dist/transform.min.js +3 -3
- package/dist/transform.min.mjs +3 -3
- package/dist/transform.mjs +35 -71
- package/dist/tryCatch.es.js +33 -17
- package/dist/tryCatch.es.min.js +3 -3
- package/dist/tryCatch.js +33 -17
- package/dist/tryCatch.min.js +3 -3
- package/dist/tryCatch.min.mjs +3 -3
- package/dist/tryCatch.mjs +33 -17
- package/dist/x/append.es.js +2 -2
- package/dist/x/append.es.min.js +2 -2
- package/dist/x/append.js +2 -2
- package/dist/x/append.min.js +2 -2
- package/dist/x/append.min.mjs +2 -2
- package/dist/x/append.mjs +2 -2
- package/dist/x/callProp.es.js +2 -2
- package/dist/x/callProp.es.min.js +2 -2
- package/dist/x/callProp.js +2 -2
- package/dist/x/callProp.min.js +2 -2
- package/dist/x/callProp.min.mjs +2 -2
- package/dist/x/callProp.mjs +2 -2
- package/dist/x/defaultsDeep.es.js +2 -2
- package/dist/x/defaultsDeep.es.min.js +2 -2
- package/dist/x/defaultsDeep.js +2 -2
- package/dist/x/defaultsDeep.min.js +2 -2
- package/dist/x/defaultsDeep.min.mjs +2 -2
- package/dist/x/defaultsDeep.mjs +2 -2
- package/dist/x/differenceWith.es.js +7 -7
- package/dist/x/differenceWith.es.min.js +3 -3
- package/dist/x/differenceWith.js +7 -7
- package/dist/x/differenceWith.min.js +2 -2
- package/dist/x/differenceWith.min.mjs +3 -3
- package/dist/x/differenceWith.mjs +7 -7
- package/dist/x/filterOut.es.js +60 -117
- package/dist/x/filterOut.es.min.js +3 -3
- package/dist/x/filterOut.js +60 -117
- package/dist/x/filterOut.min.js +3 -3
- package/dist/x/filterOut.min.mjs +3 -3
- package/dist/x/filterOut.mjs +60 -117
- package/dist/x/find.es.js +2 -2
- package/dist/x/find.es.min.js +2 -2
- package/dist/x/find.js +2 -2
- package/dist/x/find.min.js +2 -2
- package/dist/x/find.min.mjs +2 -2
- package/dist/x/find.mjs +2 -2
- package/dist/x/findIndex.es.js +2 -2
- package/dist/x/findIndex.es.min.js +2 -2
- package/dist/x/findIndex.js +2 -2
- package/dist/x/findIndex.min.js +2 -2
- package/dist/x/findIndex.min.mjs +2 -2
- package/dist/x/findIndex.mjs +2 -2
- package/dist/x/first.es.js +2 -2
- package/dist/x/first.es.min.js +2 -2
- package/dist/x/first.js +2 -2
- package/dist/x/first.min.js +2 -2
- package/dist/x/first.min.mjs +2 -2
- package/dist/x/first.mjs +2 -2
- package/dist/x/flatten.es.js +20 -207
- package/dist/x/flatten.es.min.js +3 -3
- package/dist/x/flatten.js +20 -207
- package/dist/x/flatten.min.js +3 -3
- package/dist/x/flatten.min.mjs +3 -3
- package/dist/x/flatten.mjs +20 -207
- package/dist/x/groupBy.es.js +52 -94
- package/dist/x/groupBy.es.min.js +3 -3
- package/dist/x/groupBy.js +52 -94
- package/dist/x/groupBy.min.js +3 -3
- package/dist/x/groupBy.min.mjs +3 -3
- package/dist/x/groupBy.mjs +52 -94
- package/dist/x/has.es.js +2 -2
- package/dist/x/has.es.min.js +2 -2
- package/dist/x/has.js +2 -2
- package/dist/x/has.min.js +2 -2
- package/dist/x/has.min.mjs +2 -2
- package/dist/x/has.mjs +2 -2
- package/dist/x/identity.es.js +2 -2
- package/dist/x/identity.es.min.js +2 -2
- package/dist/x/identity.js +2 -2
- package/dist/x/identity.min.js +2 -2
- package/dist/x/identity.min.mjs +2 -2
- package/dist/x/identity.mjs +2 -2
- package/dist/x/includes.es.js +2 -2
- package/dist/x/includes.es.min.js +2 -2
- package/dist/x/includes.js +2 -2
- package/dist/x/includes.min.js +2 -2
- package/dist/x/includes.min.mjs +2 -2
- package/dist/x/includes.mjs +2 -2
- package/dist/x/isDeepEqual.es.js +2 -2
- package/dist/x/isDeepEqual.es.min.js +2 -2
- package/dist/x/isDeepEqual.js +2 -2
- package/dist/x/isDeepEqual.min.js +2 -2
- package/dist/x/isDeepEqual.min.mjs +2 -2
- package/dist/x/isDeepEqual.mjs +2 -2
- package/dist/x/isEmpty.es.js +2 -2
- package/dist/x/isEmpty.es.min.js +2 -2
- package/dist/x/isEmpty.js +2 -2
- package/dist/x/isEmpty.min.js +2 -2
- package/dist/x/isEmpty.min.mjs +2 -2
- package/dist/x/isEmpty.mjs +2 -2
- package/dist/x/isEqual.es.js +2 -2
- package/dist/x/isEqual.es.min.js +2 -2
- package/dist/x/isEqual.js +2 -2
- package/dist/x/isEqual.min.js +2 -2
- package/dist/x/isEqual.min.mjs +2 -2
- package/dist/x/isEqual.mjs +2 -2
- package/dist/x/isFunction.es.js +2 -2
- package/dist/x/isFunction.es.min.js +2 -2
- package/dist/x/isFunction.js +2 -2
- package/dist/x/isFunction.min.js +2 -2
- package/dist/x/isFunction.min.mjs +2 -2
- package/dist/x/isFunction.mjs +2 -2
- package/dist/x/isIn.es.js +2 -2
- package/dist/x/isIn.es.min.js +2 -2
- package/dist/x/isIn.js +2 -2
- package/dist/x/isIn.min.js +2 -2
- package/dist/x/isIn.min.mjs +2 -2
- package/dist/x/isIn.mjs +2 -2
- package/dist/x/isObject.es.js +2 -2
- package/dist/x/isObject.es.min.js +2 -2
- package/dist/x/isObject.js +2 -2
- package/dist/x/isObject.min.js +2 -2
- package/dist/x/isObject.min.mjs +2 -2
- package/dist/x/isObject.mjs +2 -2
- package/dist/x/isString.es.js +2 -2
- package/dist/x/isString.es.min.js +2 -2
- package/dist/x/isString.js +2 -2
- package/dist/x/isString.min.js +2 -2
- package/dist/x/isString.min.mjs +2 -2
- package/dist/x/isString.mjs +2 -2
- package/dist/x/keys.es.js +2 -2
- package/dist/x/keys.es.min.js +2 -2
- package/dist/x/keys.js +2 -2
- package/dist/x/keys.min.js +2 -2
- package/dist/x/keys.min.mjs +2 -2
- package/dist/x/keys.mjs +2 -2
- package/dist/x/last.es.js +2 -2
- package/dist/x/last.es.min.js +2 -2
- package/dist/x/last.js +2 -2
- package/dist/x/last.min.js +2 -2
- package/dist/x/last.min.mjs +2 -2
- package/dist/x/last.mjs +2 -2
- package/dist/x/maxBy.es.js +59 -6
- package/dist/x/maxBy.es.min.js +3 -3
- package/dist/x/maxBy.js +59 -6
- package/dist/x/maxBy.min.js +3 -3
- package/dist/x/maxBy.min.mjs +3 -3
- package/dist/x/maxBy.mjs +59 -6
- package/dist/x/noop.es.js +2 -2
- package/dist/x/noop.es.min.js +2 -2
- package/dist/x/noop.js +2 -2
- package/dist/x/noop.min.js +2 -2
- package/dist/x/noop.min.mjs +2 -2
- package/dist/x/noop.mjs +2 -2
- package/dist/x/pluck.es.js +32 -103
- package/dist/x/pluck.es.min.js +3 -3
- package/dist/x/pluck.js +32 -103
- package/dist/x/pluck.min.js +3 -3
- package/dist/x/pluck.min.mjs +3 -3
- package/dist/x/pluck.mjs +32 -103
- package/dist/x/prepend.es.js +2 -2
- package/dist/x/prepend.es.min.js +2 -2
- package/dist/x/prepend.js +2 -2
- package/dist/x/prepend.min.js +2 -2
- package/dist/x/prepend.min.mjs +2 -2
- package/dist/x/prepend.mjs +2 -2
- package/dist/x/size.es.js +2 -2
- package/dist/x/size.es.min.js +2 -2
- package/dist/x/size.js +2 -2
- package/dist/x/size.min.js +2 -2
- package/dist/x/size.min.mjs +2 -2
- package/dist/x/size.mjs +2 -2
- package/dist/x/trace.es.js +2 -9
- package/dist/x/trace.es.min.js +3 -3
- package/dist/x/trace.js +2 -9
- package/dist/x/trace.min.js +3 -3
- package/dist/x/trace.min.mjs +3 -3
- package/dist/x/trace.mjs +2 -9
- package/dist/x/unionWith.es.js +2 -2
- package/dist/x/unionWith.es.min.js +2 -2
- package/dist/x/unionWith.js +2 -2
- package/dist/x/unionWith.min.js +2 -2
- package/dist/x/unionWith.min.mjs +2 -2
- package/dist/x/unionWith.mjs +2 -2
- package/dist/x/uniq.es.js +2 -2
- package/dist/x/uniq.es.min.js +2 -2
- package/dist/x/uniq.js +2 -2
- package/dist/x/uniq.min.js +2 -2
- package/dist/x/uniq.min.mjs +2 -2
- package/dist/x/uniq.mjs +2 -2
- package/dist/x/unless.es.js +2 -2
- package/dist/x/unless.es.min.js +2 -2
- package/dist/x/unless.js +2 -2
- package/dist/x/unless.min.js +2 -2
- package/dist/x/unless.min.mjs +2 -2
- package/dist/x/unless.mjs +2 -2
- package/dist/x/values.es.js +2 -2
- package/dist/x/values.es.min.js +2 -2
- package/dist/x/values.js +2 -2
- package/dist/x/values.min.js +2 -2
- package/dist/x/values.min.mjs +2 -2
- package/dist/x/values.mjs +2 -2
- package/dist/x/when.es.js +2 -2
- package/dist/x/when.es.min.js +2 -2
- package/dist/x/when.js +2 -2
- package/dist/x/when.min.js +2 -2
- package/dist/x/when.min.mjs +2 -2
- package/dist/x/when.mjs +2 -2
- package/dist-test.js +9 -2042
- package/eq.js +21 -63
- package/es.js +730 -869
- package/every.js +94 -0
- package/filter.js +23 -91
- package/flatMap.js +75 -70
- package/forEach.js +82 -0
- package/get.js +23 -6
- package/global.js +6 -4
- package/gt.js +15 -58
- package/gte.js +14 -57
- package/index.js +730 -869
- package/lt.js +17 -60
- package/lte.js +14 -57
- package/map.js +9 -94
- package/memory-usage/reduce.js +2 -2
- package/not.js +27 -45
- package/omit.js +4 -0
- package/or.js +50 -33
- package/package.json +7 -7
- package/pick.js +5 -1
- package/pipe.js +13 -50
- package/reduce.js +42 -51
- package/rubico.js +10 -8
- package/set.js +43 -10
- package/some.js +105 -0
- package/switchCase.js +13 -3
- package/tap.js +0 -24
- package/test.js +847 -1096
- package/thunkify.js +9 -0
- package/transform.js +31 -16
- package/tryCatch.js +19 -15
- package/x/differenceWith.js +3 -3
- package/x/filterOut.test.js +6 -6
- package/x/flatten.js +1 -1
- package/x/flatten.test.js +0 -8
- package/x/index.js +0 -2
- package/x/pluck.js +18 -27
- package/x/pluck.test.js +3 -7
- package/x/timeInLoop.js +16 -25
- package/x/timeInLoop.test.js +8 -4
- package/any.js +0 -82
- package/dist/any.es.min.js +0 -7
- package/dist/any.min.js +0 -8
- package/dist/any.min.mjs +0 -7
- package/dist/fork.es.js +0 -159
- package/dist/fork.es.min.js +0 -7
- package/dist/fork.js +0 -166
- package/dist/fork.min.js +0 -8
- package/dist/fork.min.mjs +0 -7
- package/dist/fork.mjs +0 -159
- package/dist/x/forEach.es.min.js +0 -7
- package/dist/x/forEach.min.js +0 -8
- package/dist/x/forEach.min.mjs +0 -7
- package/fork.js +0 -101
- package/x/forEach.js +0 -93
- package/x/forEach.test.js +0 -218
- /package/{benchmarks → archive/benchmarks-v1.9.7}/any.js +0 -0
- /package/{x/forEach.benchmark.js → archive/benchmarks-v1.9.7/forEach.js} +0 -0
- /package/{benchmarks → archive/benchmarks-v1.9.7}/fork.js +0 -0
- /package/{benchmarks → archive/benchmarks-v1.9.7}/integration.js +0 -0
- /package/{benchmarks → archive/benchmarks-v1.9.7}/misc.js +0 -0
package/dist/rubico.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico
|
|
2
|
+
* rubico v2.0.0
|
|
3
3
|
* https://github.com/a-synchronous/rubico
|
|
4
|
-
* (c) 2019-
|
|
4
|
+
* (c) 2019-2023 Richard Tong
|
|
5
5
|
* rubico may be freely distributed under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -11,10 +11,22 @@
|
|
|
11
11
|
else (root.rubico = rubico) // Browser
|
|
12
12
|
}(typeof globalThis == 'object' ? globalThis : this, (function () { 'use strict'
|
|
13
13
|
|
|
14
|
-
const noop = function () {}
|
|
15
|
-
|
|
16
14
|
const isPromise = value => value != null && typeof value.then == 'function'
|
|
17
15
|
|
|
16
|
+
const areAnyValuesPromises = function (values) {
|
|
17
|
+
const length = values.length
|
|
18
|
+
let index = -1
|
|
19
|
+
while (++index < length) {
|
|
20
|
+
const value = values[index]
|
|
21
|
+
if (isPromise(value)) {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const promiseAll = Promise.all.bind(Promise)
|
|
29
|
+
|
|
18
30
|
const funcConcat = (
|
|
19
31
|
funcA, funcB,
|
|
20
32
|
) => function pipedFunction(...args) {
|
|
@@ -24,82 +36,69 @@ const funcConcat = (
|
|
|
24
36
|
: funcB(intermediate)
|
|
25
37
|
}
|
|
26
38
|
|
|
27
|
-
const
|
|
28
|
-
funcA, funcB,
|
|
29
|
-
) => function pipedFunction(...args) {
|
|
30
|
-
return funcB(funcA(...args))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const objectProto = Object.prototype
|
|
39
|
+
const funcApply = (func, args) => func(...args)
|
|
34
40
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const objectToString = value => nativeObjectToString.call(value)
|
|
38
|
-
|
|
39
|
-
const generatorFunctionTag = '[object GeneratorFunction]'
|
|
41
|
+
const __ = Symbol.for('placeholder')
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
// argument resolver for curry2
|
|
44
|
+
const curry2ResolveArg0 = (
|
|
45
|
+
baseFunc, arg1,
|
|
46
|
+
) => function arg0Resolver(arg0) {
|
|
47
|
+
return baseFunc(arg0, arg1)
|
|
48
|
+
}
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
// argument resolver for curry2
|
|
51
|
+
const curry2ResolveArg1 = (
|
|
52
|
+
baseFunc, arg0,
|
|
53
|
+
) => function arg1Resolver(arg1) {
|
|
54
|
+
return baseFunc(arg0, arg1)
|
|
55
|
+
}
|
|
44
56
|
|
|
45
|
-
const
|
|
57
|
+
const curry2 = function (baseFunc, arg0, arg1) {
|
|
58
|
+
return arg0 == __
|
|
59
|
+
? curry2ResolveArg0(baseFunc, arg1)
|
|
60
|
+
: curry2ResolveArg1(baseFunc, arg0)
|
|
61
|
+
}
|
|
46
62
|
|
|
47
63
|
const pipe = function (...args) {
|
|
48
64
|
const funcs = args.pop()
|
|
65
|
+
const pipeline = funcs.reduce(funcConcat)
|
|
49
66
|
|
|
50
|
-
if (args.length
|
|
51
|
-
return
|
|
67
|
+
if (args.length == 0) {
|
|
68
|
+
return pipeline
|
|
52
69
|
}
|
|
53
70
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return function pipeline(...args) {
|
|
57
|
-
const firstArg = args[0]
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
typeof firstArg == 'function'
|
|
61
|
-
&& !isGeneratorFunction(firstArg)
|
|
62
|
-
&& !isAsyncGeneratorFunction(firstArg)
|
|
63
|
-
) {
|
|
64
|
-
if (functionComposition == noop) {
|
|
65
|
-
functionComposition = funcs.reduceRight(funcConcat)
|
|
66
|
-
}
|
|
67
|
-
return functionComposition(firstArg)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (functionPipeline == noop) {
|
|
71
|
-
functionPipeline = funcs.reduce(funcConcat)
|
|
72
|
-
}
|
|
73
|
-
return functionPipeline(...args)
|
|
71
|
+
if (areAnyValuesPromises(args)) {
|
|
72
|
+
return promiseAll(args).then(curry2(funcApply, pipeline, __))
|
|
74
73
|
}
|
|
75
|
-
}
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
pipe.sync = pipeSync
|
|
75
|
+
return pipeline(...args)
|
|
76
|
+
}
|
|
81
77
|
|
|
82
|
-
const
|
|
78
|
+
const compose = function (...args) {
|
|
79
|
+
const funcs = args.pop()
|
|
80
|
+
const composition = funcs.reduceRight(funcConcat)
|
|
83
81
|
|
|
84
|
-
|
|
82
|
+
if (args.length == 0) {
|
|
83
|
+
return composition
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
result = Array(funcsLength)
|
|
89
|
-
let funcsIndex = -1, isAsync = false
|
|
90
|
-
while (++funcsIndex < funcsLength) {
|
|
91
|
-
const resultItem = funcs[funcsIndex](...args)
|
|
92
|
-
if (isPromise(resultItem)) {
|
|
93
|
-
isAsync = true
|
|
94
|
-
}
|
|
95
|
-
result[funcsIndex] = resultItem
|
|
86
|
+
if (areAnyValuesPromises(args)) {
|
|
87
|
+
return promiseAll(args).then(curry2(funcApply, composition, __))
|
|
96
88
|
}
|
|
97
|
-
|
|
89
|
+
|
|
90
|
+
return composition(...args)
|
|
98
91
|
}
|
|
99
92
|
|
|
100
93
|
const always = value => function getter() { return value }
|
|
101
94
|
|
|
102
|
-
const
|
|
95
|
+
const thunkifyArgs = (func, args) => function thunk() {
|
|
96
|
+
return func(...args)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const thunkConditional = (
|
|
100
|
+
conditionalExpression, thunkOnTruthy, thunkOnFalsy,
|
|
101
|
+
) => conditionalExpression ? thunkOnTruthy() : thunkOnFalsy()
|
|
103
102
|
|
|
104
103
|
// argument resolver for curry3
|
|
105
104
|
const curry3ResolveArg0 = (
|
|
@@ -132,22 +131,62 @@ const curry3 = function (baseFunc, arg0, arg1, arg2) {
|
|
|
132
131
|
return curry3ResolveArg2(baseFunc, arg0, arg1)
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const tap = func => function tapping(...args) {
|
|
135
|
+
const result = args[0],
|
|
136
|
+
call = func(...args)
|
|
137
|
+
return isPromise(call) ? call.then(always(result)) : result
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
tap.if = (predicate, func) => function tappingIf(...args) {
|
|
141
|
+
const predication = predicate(...args)
|
|
142
|
+
if (isPromise(predication)) {
|
|
143
|
+
return predication.then(curry3(
|
|
144
|
+
thunkConditional, __, thunkifyArgs(tap(func), args), always(args[0])))
|
|
145
|
+
}
|
|
146
|
+
if (predication) {
|
|
147
|
+
const execution = func(...args)
|
|
148
|
+
if (isPromise(execution)) {
|
|
149
|
+
return execution.then(always(args[0]))
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return args[0]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const isArray = Array.isArray
|
|
156
|
+
|
|
157
|
+
// argument resolver for curryArgs2
|
|
158
|
+
const curryArgs2ResolveArgs0 = (
|
|
159
|
+
baseFunc, arg1, arg2,
|
|
160
|
+
) => function args0Resolver(...args) {
|
|
161
|
+
return baseFunc(args, arg1)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// argument resolver for curryArgs2
|
|
165
|
+
const curryArgs2ResolveArgs1 = (
|
|
166
|
+
baseFunc, arg0, arg2,
|
|
167
|
+
) => function arg1Resolver(...args) {
|
|
168
|
+
return baseFunc(arg0, args)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const curryArgs2 = function (baseFunc, arg0, arg1) {
|
|
172
|
+
if (arg0 == __) {
|
|
173
|
+
return curryArgs2ResolveArgs0(baseFunc, arg1)
|
|
174
|
+
}
|
|
175
|
+
return curryArgs2ResolveArgs1(baseFunc, arg0)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const functionArrayAll = function (funcs, args) {
|
|
179
|
+
const funcsLength = funcs.length,
|
|
180
|
+
result = Array(funcsLength)
|
|
181
|
+
let funcsIndex = -1, isAsync = false
|
|
182
|
+
while (++funcsIndex < funcsLength) {
|
|
183
|
+
const resultItem = funcs[funcsIndex](...args)
|
|
144
184
|
if (isPromise(resultItem)) {
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
result[key] = resultItem
|
|
185
|
+
isAsync = true
|
|
148
186
|
}
|
|
187
|
+
result[funcsIndex] = resultItem
|
|
149
188
|
}
|
|
150
|
-
return
|
|
189
|
+
return isAsync ? promiseAll(result) : result
|
|
151
190
|
}
|
|
152
191
|
|
|
153
192
|
// argument resolver for curry4
|
|
@@ -191,7 +230,12 @@ const curry4 = function (baseFunc, arg0, arg1, arg2, arg3) {
|
|
|
191
230
|
return curry4ResolveArg3(baseFunc, arg0, arg1, arg2)
|
|
192
231
|
}
|
|
193
232
|
|
|
194
|
-
const
|
|
233
|
+
const objectSet = function (object, property, value) {
|
|
234
|
+
object[property] = value
|
|
235
|
+
return object
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const asyncFunctionArrayAllSeries = async function (funcs, args, result, funcsIndex) {
|
|
195
239
|
const funcsLength = funcs.length
|
|
196
240
|
while (++funcsIndex < funcsLength) {
|
|
197
241
|
const resultItem = funcs[funcsIndex](...args)
|
|
@@ -200,7 +244,7 @@ const asyncFuncAllSeries = async function (funcs, args, result, funcsIndex) {
|
|
|
200
244
|
return result
|
|
201
245
|
}
|
|
202
246
|
|
|
203
|
-
const
|
|
247
|
+
const functionArrayAllSeries = function (funcs, args) {
|
|
204
248
|
const funcsLength = funcs.length, result = []
|
|
205
249
|
let funcsIndex = -1
|
|
206
250
|
while (++funcsIndex < funcsLength) {
|
|
@@ -208,94 +252,106 @@ const funcAllSeries = funcs => function allFuncsSeries(...args) {
|
|
|
208
252
|
if (isPromise(resultItem)) {
|
|
209
253
|
return resultItem.then(funcConcat(
|
|
210
254
|
curry3(objectSet, result, funcsIndex, __),
|
|
211
|
-
curry4(
|
|
255
|
+
curry4(asyncFunctionArrayAllSeries, funcs, args, __, funcsIndex)))
|
|
212
256
|
}
|
|
213
257
|
result[funcsIndex] = resultItem
|
|
214
258
|
}
|
|
215
259
|
return result
|
|
216
260
|
}
|
|
217
261
|
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
262
|
+
const functionObjectAll = function (funcs, args) {
|
|
263
|
+
const result = {}, promises = []
|
|
264
|
+
for (const key in funcs) {
|
|
265
|
+
const resultItem = funcs[key](...args)
|
|
266
|
+
if (isPromise(resultItem)) {
|
|
267
|
+
promises.push(resultItem.then(curry3(objectSet, result, key, __)))
|
|
268
|
+
} else {
|
|
269
|
+
result[key] = resultItem
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return promises.length == 0 ? result : promiseAll(promises).then(always(result))
|
|
273
|
+
}
|
|
221
274
|
|
|
222
|
-
const
|
|
275
|
+
const all = function (...args) {
|
|
276
|
+
const funcs = args.pop()
|
|
277
|
+
if (args.length == 0) {
|
|
278
|
+
return isArray(funcs)
|
|
279
|
+
? curryArgs2(functionArrayAll, funcs, __)
|
|
280
|
+
: curryArgs2(functionObjectAll, funcs, __)
|
|
281
|
+
}
|
|
223
282
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return isPromise(result)
|
|
229
|
-
? result.then(curry3(objectAssign, {}, value, __))
|
|
230
|
-
: ({ ...value, ...result })
|
|
283
|
+
if (areAnyValuesPromises(args)) {
|
|
284
|
+
return isArray(funcs)
|
|
285
|
+
? promiseAll(args).then(curry2(functionArrayAll, funcs, __))
|
|
286
|
+
: promiseAll(args).then(curry2(functionObjectAll, funcs, __))
|
|
231
287
|
}
|
|
232
|
-
}
|
|
233
288
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
289
|
+
return isArray(funcs)
|
|
290
|
+
? functionArrayAll(funcs, args)
|
|
291
|
+
: functionObjectAll(funcs, args)
|
|
237
292
|
}
|
|
238
293
|
|
|
239
|
-
|
|
240
|
-
|
|
294
|
+
all.series = function allSeries(...args) {
|
|
295
|
+
const funcs = args.pop()
|
|
296
|
+
if (args.length == 0) {
|
|
297
|
+
return curryArgs2(functionArrayAllSeries, funcs, __)
|
|
298
|
+
}
|
|
299
|
+
if (areAnyValuesPromises(args)) {
|
|
300
|
+
return promiseAll(args).then(curry2(functionArrayAllSeries, funcs, __))
|
|
301
|
+
}
|
|
302
|
+
return functionArrayAllSeries(funcs, args)
|
|
241
303
|
}
|
|
242
304
|
|
|
243
|
-
const
|
|
244
|
-
conditionalExpression, thunkOnTruthy, thunkOnFalsy,
|
|
245
|
-
) => conditionalExpression ? thunkOnTruthy() : thunkOnFalsy()
|
|
305
|
+
const objectAssign = Object.assign
|
|
246
306
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return isPromise(
|
|
307
|
+
// _assign(object Object, funcs Object<function>) -> Promise|Object
|
|
308
|
+
const _assign = function (object, funcs) {
|
|
309
|
+
const result = functionObjectAll(funcs, [object])
|
|
310
|
+
return isPromise(result)
|
|
311
|
+
? result.then(curry3(objectAssign, {}, object, __))
|
|
312
|
+
: ({ ...object, ...result })
|
|
251
313
|
}
|
|
252
314
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const predication = predicate(...args)
|
|
257
|
-
if (isPromise(predication)) {
|
|
258
|
-
return predication.then(curry3(
|
|
259
|
-
thunkConditional, __, thunkifyArgs(tap(func), args), always(args[0])))
|
|
260
|
-
}
|
|
261
|
-
if (predication) {
|
|
262
|
-
const execution = func(...args)
|
|
263
|
-
if (isPromise(execution)) {
|
|
264
|
-
return execution.then(always(args[0]))
|
|
265
|
-
}
|
|
315
|
+
const assign = function (arg0, arg1) {
|
|
316
|
+
if (arg1 == null) {
|
|
317
|
+
return curry2(_assign, __, arg0)
|
|
266
318
|
}
|
|
267
|
-
return
|
|
319
|
+
return isPromise(arg0)
|
|
320
|
+
? arg0.then(curry2(_assign, __, arg1))
|
|
321
|
+
: _assign(arg0, arg1)
|
|
268
322
|
}
|
|
269
323
|
|
|
270
324
|
const catcherApply = function (catcher, err, args) {
|
|
271
325
|
return catcher(err, ...args)
|
|
272
326
|
}
|
|
273
327
|
|
|
328
|
+
// _tryCatch(tryer function, catcher function, args Array) -> Promise
|
|
329
|
+
const _tryCatch = function (tryer, catcher, args) {
|
|
330
|
+
try {
|
|
331
|
+
const result = tryer(...args)
|
|
332
|
+
return isPromise(result)
|
|
333
|
+
? result.catch(curry3(catcherApply, catcher, __, args))
|
|
334
|
+
: result
|
|
335
|
+
} catch (error) {
|
|
336
|
+
return catcher(error, ...args)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
274
340
|
const tryCatch = function (...args) {
|
|
275
341
|
if (args.length > 2) {
|
|
276
342
|
const catcher = args.pop(),
|
|
277
343
|
tryer = args.pop()
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
? result.catch(curry3(catcherApply, catcher, __, args))
|
|
282
|
-
: result
|
|
283
|
-
} catch (error) {
|
|
284
|
-
return catcher(error, ...args)
|
|
344
|
+
if (areAnyValuesPromises(args)) {
|
|
345
|
+
return promiseAll(args)
|
|
346
|
+
.then(curry3(_tryCatch, tryer, catcher, __))
|
|
285
347
|
}
|
|
348
|
+
return _tryCatch(tryer, catcher, args)
|
|
286
349
|
}
|
|
287
350
|
|
|
288
351
|
const tryer = args[0],
|
|
289
352
|
catcher = args[1]
|
|
290
353
|
return function tryCatcher(...args) {
|
|
291
|
-
|
|
292
|
-
const result = tryer(...args)
|
|
293
|
-
return isPromise(result)
|
|
294
|
-
? result.catch(curry3(catcherApply, catcher, __, args))
|
|
295
|
-
: result
|
|
296
|
-
} catch (error) {
|
|
297
|
-
return catcher(error, ...args)
|
|
298
|
-
}
|
|
354
|
+
return _tryCatch(tryer, catcher, args)
|
|
299
355
|
}
|
|
300
356
|
}
|
|
301
357
|
|
|
@@ -383,13 +439,49 @@ const nonfunctionsConditional = function (array, index) {
|
|
|
383
439
|
return array[index]
|
|
384
440
|
}
|
|
385
441
|
|
|
386
|
-
|
|
442
|
+
// argument resolver for curryArgs3
|
|
443
|
+
const curryArgs3ResolveArgs0 = (
|
|
444
|
+
baseFunc, arg1, arg2,
|
|
445
|
+
) => function args0Resolver(...args) {
|
|
446
|
+
return baseFunc(args, arg1, arg2)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// argument resolver for curryArgs3
|
|
450
|
+
const curryArgs3ResolveArgs1 = (
|
|
451
|
+
baseFunc, arg0, arg2,
|
|
452
|
+
) => function arg1Resolver(...args) {
|
|
453
|
+
return baseFunc(arg0, args, arg2)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// argument resolver for curryArgs3
|
|
457
|
+
const curryArgs3ResolveArgs2 = (
|
|
458
|
+
baseFunc, arg0, arg1,
|
|
459
|
+
) => function arg2Resolver(...args) {
|
|
460
|
+
return baseFunc(arg0, arg1, args)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const curryArgs3 = function (baseFunc, arg0, arg1, arg2) {
|
|
464
|
+
if (arg0 == __) {
|
|
465
|
+
return curryArgs3ResolveArgs0(baseFunc, arg1, arg2)
|
|
466
|
+
}
|
|
467
|
+
if (arg1 == __) {
|
|
468
|
+
return curryArgs3ResolveArgs1(baseFunc, arg0, arg2)
|
|
469
|
+
}
|
|
470
|
+
return curryArgs3ResolveArgs2(baseFunc, arg0, arg1)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const switchCase = (...args) => {
|
|
474
|
+
const values = args.pop()
|
|
387
475
|
if (areAllValuesNonfunctions(values)) {
|
|
388
476
|
return nonfunctionsConditional(values, -2)
|
|
389
477
|
}
|
|
390
|
-
|
|
391
|
-
return arrayConditional
|
|
478
|
+
if (args.length == 0) {
|
|
479
|
+
return curryArgs3(arrayConditional, values, __, -2)
|
|
480
|
+
}
|
|
481
|
+
if (areAnyValuesPromises(args)) {
|
|
482
|
+
return promiseAll(args).then(curry3(arrayConditional, values, __, -2))
|
|
392
483
|
}
|
|
484
|
+
return arrayConditional(values, args, -2)
|
|
393
485
|
}
|
|
394
486
|
|
|
395
487
|
const symbolIterator = Symbol.iterator
|
|
@@ -428,26 +520,6 @@ const MappingAsyncIterator = (asyncIterator, mapper) => ({
|
|
|
428
520
|
}
|
|
429
521
|
})
|
|
430
522
|
|
|
431
|
-
// argument resolver for curry2
|
|
432
|
-
const curry2ResolveArg0 = (
|
|
433
|
-
baseFunc, arg1,
|
|
434
|
-
) => function arg0Resolver(arg0) {
|
|
435
|
-
return baseFunc(arg0, arg1)
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// argument resolver for curry2
|
|
439
|
-
const curry2ResolveArg1 = (
|
|
440
|
-
baseFunc, arg0,
|
|
441
|
-
) => function arg1Resolver(arg1) {
|
|
442
|
-
return baseFunc(arg0, arg1)
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const curry2 = function (baseFunc, arg0, arg1) {
|
|
446
|
-
return arg0 == __
|
|
447
|
-
? curry2ResolveArg0(baseFunc, arg1)
|
|
448
|
-
: curry2ResolveArg1(baseFunc, arg0)
|
|
449
|
-
}
|
|
450
|
-
|
|
451
523
|
const isObject = value => {
|
|
452
524
|
if (value == null) {
|
|
453
525
|
return false
|
|
@@ -473,31 +545,6 @@ const arrayMap = function (array, mapper) {
|
|
|
473
545
|
return isAsync ? promiseAll(result) : result
|
|
474
546
|
}
|
|
475
547
|
|
|
476
|
-
const generatorFunctionMap = (
|
|
477
|
-
generatorFunc, mapper,
|
|
478
|
-
) => function* mappingGeneratorFunc(...args) {
|
|
479
|
-
for (const item of generatorFunc(...args)) {
|
|
480
|
-
yield mapper(item)
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
const asyncGeneratorFunctionMap = function (asyncGeneratorFunc, mapper) {
|
|
485
|
-
return async function* mappingAsyncGeneratorFunc(...args) {
|
|
486
|
-
for await (const item of asyncGeneratorFunc(...args)) {
|
|
487
|
-
yield mapper(item)
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
const reducerMap = (
|
|
493
|
-
reducer, mapper,
|
|
494
|
-
) => function mappingReducer(result, reducerItem) {
|
|
495
|
-
const mappingReducerItem = mapper(reducerItem)
|
|
496
|
-
return isPromise(mappingReducerItem)
|
|
497
|
-
? mappingReducerItem.then(curry2(reducer, result, __))
|
|
498
|
-
: reducer(result, mappingReducerItem)
|
|
499
|
-
}
|
|
500
|
-
|
|
501
548
|
const callPropUnary = (value, property, arg0) => value[property](arg0)
|
|
502
549
|
|
|
503
550
|
const stringMap = function (string, mapper) {
|
|
@@ -608,6 +655,11 @@ const arrayMapSeries = function (array, mapper) {
|
|
|
608
655
|
return result
|
|
609
656
|
}
|
|
610
657
|
|
|
658
|
+
const tapSync = func => function tapping(...args) {
|
|
659
|
+
func(...args)
|
|
660
|
+
return args[0]
|
|
661
|
+
}
|
|
662
|
+
|
|
611
663
|
const promiseRace = Promise.race.bind(Promise)
|
|
612
664
|
|
|
613
665
|
const arrayMapPoolAsync = async function (
|
|
@@ -653,38 +705,6 @@ const arrayMapPool = function (array, mapper, concurrentLimit) {
|
|
|
653
705
|
return result
|
|
654
706
|
}
|
|
655
707
|
|
|
656
|
-
const arrayMapWithIndex = function (array, mapper) {
|
|
657
|
-
const arrayLength = array.length,
|
|
658
|
-
result = Array(arrayLength)
|
|
659
|
-
let index = -1, isAsync = false
|
|
660
|
-
while (++index < arrayLength) {
|
|
661
|
-
const resultItem = mapper(array[index], index, array)
|
|
662
|
-
if (isPromise(resultItem)) {
|
|
663
|
-
isAsync = true
|
|
664
|
-
}
|
|
665
|
-
result[index] = resultItem
|
|
666
|
-
}
|
|
667
|
-
return isAsync ? promiseAll(result) : result
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
671
|
-
const hasOwn = (obj, key) => hasOwnProperty.call(obj, key)
|
|
672
|
-
|
|
673
|
-
const objectMapOwn = function (object, mapper) {
|
|
674
|
-
const result = {}
|
|
675
|
-
let isAsync = false
|
|
676
|
-
for (const key in object) {
|
|
677
|
-
if (hasOwn(object, key)) {
|
|
678
|
-
const resultItem = mapper(object[key])
|
|
679
|
-
if (isPromise(resultItem)) {
|
|
680
|
-
isAsync = true
|
|
681
|
-
}
|
|
682
|
-
result[key] = resultItem
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return isAsync ? promiseObjectAll(result) : result
|
|
686
|
-
}
|
|
687
|
-
|
|
688
708
|
const _curryArity = (arity, func, args) => function curried(...curriedArgs) {
|
|
689
709
|
const argsLength = args.length,
|
|
690
710
|
curriedArgsLength = curriedArgs.length,
|
|
@@ -792,15 +812,6 @@ const _map = function (value, mapper) {
|
|
|
792
812
|
if (isArray(value)) {
|
|
793
813
|
return arrayMap(value, mapper)
|
|
794
814
|
}
|
|
795
|
-
if (typeof value == 'function') {
|
|
796
|
-
if (isGeneratorFunction(value)) {
|
|
797
|
-
return generatorFunctionMap(value, mapper)
|
|
798
|
-
}
|
|
799
|
-
if (isAsyncGeneratorFunction(value)) {
|
|
800
|
-
return asyncGeneratorFunctionMap(value, mapper)
|
|
801
|
-
}
|
|
802
|
-
return reducerMap(value, mapper)
|
|
803
|
-
}
|
|
804
815
|
if (value == null) {
|
|
805
816
|
return value
|
|
806
817
|
}
|
|
@@ -834,10 +845,15 @@ const _map = function (value, mapper) {
|
|
|
834
845
|
|
|
835
846
|
const map = (...args) => {
|
|
836
847
|
const mapper = args.pop()
|
|
837
|
-
if (args.length
|
|
838
|
-
return _map
|
|
848
|
+
if (args.length == 0) {
|
|
849
|
+
return curry2(_map, __, mapper)
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const collection = args[0]
|
|
853
|
+
if (isPromise(collection)) {
|
|
854
|
+
return collection.then(curry2(_map, __, mapper))
|
|
839
855
|
}
|
|
840
|
-
return
|
|
856
|
+
return _map(collection, mapper)
|
|
841
857
|
}
|
|
842
858
|
|
|
843
859
|
map.entries = function mapEntries(mapper) {
|
|
@@ -869,20 +885,6 @@ map.pool = (concurrencyLimit, mapper) => function concurrentPoolMapping(value) {
|
|
|
869
885
|
throw new TypeError(`${value} is not an Array`)
|
|
870
886
|
}
|
|
871
887
|
|
|
872
|
-
map.withIndex = mapper => function mappingWithIndex(value) {
|
|
873
|
-
if (isArray(value)) {
|
|
874
|
-
return arrayMapWithIndex(value, mapper)
|
|
875
|
-
}
|
|
876
|
-
throw new TypeError(`${value} is not an Array`)
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
map.own = mapper => function mappingOwnProperties(value) {
|
|
880
|
-
if (isObject(value) && !isArray(value)) {
|
|
881
|
-
return objectMapOwn(value, mapper)
|
|
882
|
-
}
|
|
883
|
-
throw new TypeError(`${value} is not an Object`)
|
|
884
|
-
}
|
|
885
|
-
|
|
886
888
|
const FilteringIterator = (iterator, predicate) => ({
|
|
887
889
|
[symbolIterator]() {
|
|
888
890
|
return this
|
|
@@ -952,12 +954,11 @@ const arrayFilter = function (array, predicate) {
|
|
|
952
954
|
resultIndex = -1
|
|
953
955
|
while (++index < arrayLength) {
|
|
954
956
|
const item = array[index],
|
|
955
|
-
shouldIncludeItem = predicate(item)
|
|
957
|
+
shouldIncludeItem = predicate(item, index, array)
|
|
956
958
|
if (isPromise(shouldIncludeItem)) {
|
|
957
959
|
return promiseAll(
|
|
958
|
-
arrayExtendMap(
|
|
959
|
-
|
|
960
|
-
curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
960
|
+
arrayExtendMap([shouldIncludeItem], array, predicate, index)
|
|
961
|
+
).then(curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
961
962
|
}
|
|
962
963
|
if (shouldIncludeItem) {
|
|
963
964
|
result[++resultIndex] = item
|
|
@@ -966,31 +967,6 @@ const arrayFilter = function (array, predicate) {
|
|
|
966
967
|
return result
|
|
967
968
|
}
|
|
968
969
|
|
|
969
|
-
const generatorFunctionFilter = (
|
|
970
|
-
generatorFunction, predicate,
|
|
971
|
-
) => function* filteringGeneratorFunction(...args) {
|
|
972
|
-
yield* FilteringIterator(generatorFunction(...args), predicate)
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
const asyncGeneratorFunctionFilter = (
|
|
976
|
-
asyncGeneratorFunction, predicate,
|
|
977
|
-
) => async function* filteringAsyncGeneratorFunction(...args) {
|
|
978
|
-
yield* FilteringAsyncIterator(asyncGeneratorFunction(...args), predicate)
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
const reducerFilter = (
|
|
982
|
-
reducer, predicate,
|
|
983
|
-
) => function filteringReducer(result, item) {
|
|
984
|
-
const shouldInclude = predicate(item)
|
|
985
|
-
return isPromise(shouldInclude)
|
|
986
|
-
? shouldInclude.then(curry3(
|
|
987
|
-
thunkConditional,
|
|
988
|
-
__,
|
|
989
|
-
thunkify2(reducer, result, item),
|
|
990
|
-
always(result)))
|
|
991
|
-
: shouldInclude ? reducer(result, item) : result
|
|
992
|
-
}
|
|
993
|
-
|
|
994
970
|
const stringFilter = function (string, predicate) {
|
|
995
971
|
const filteredCharactersArray = arrayFilter(string, predicate)
|
|
996
972
|
return isPromise(filteredCharactersArray)
|
|
@@ -1002,6 +978,8 @@ const thunkify1 = (func, arg0) => function thunk() {
|
|
|
1002
978
|
return func(arg0)
|
|
1003
979
|
}
|
|
1004
980
|
|
|
981
|
+
const noop = function () {}
|
|
982
|
+
|
|
1005
983
|
const setFilter = function (value, predicate) {
|
|
1006
984
|
const result = new Set(),
|
|
1007
985
|
resultAdd = result.add.bind(result),
|
|
@@ -1068,53 +1046,10 @@ const objectFilter = function (object, predicate) {
|
|
|
1068
1046
|
: promiseAll(promises).then(always(result))
|
|
1069
1047
|
}
|
|
1070
1048
|
|
|
1071
|
-
const arrayExtendMapWithIndex = function (
|
|
1072
|
-
array, values, valuesMapper, valuesIndex,
|
|
1073
|
-
) {
|
|
1074
|
-
const valuesLength = values.length
|
|
1075
|
-
let arrayIndex = array.length - 1
|
|
1076
|
-
|
|
1077
|
-
while (++valuesIndex < valuesLength) {
|
|
1078
|
-
array[++arrayIndex] = valuesMapper(
|
|
1079
|
-
values[valuesIndex], valuesIndex, values)
|
|
1080
|
-
}
|
|
1081
|
-
return array
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
const arrayFilterWithIndex = function (array, predicate) {
|
|
1085
|
-
const arrayLength = array.length,
|
|
1086
|
-
result = []
|
|
1087
|
-
let index = -1,
|
|
1088
|
-
resultIndex = -1
|
|
1089
|
-
while (++index < arrayLength) {
|
|
1090
|
-
const item = array[index],
|
|
1091
|
-
shouldIncludeItem = predicate(item, index, array)
|
|
1092
|
-
if (isPromise(shouldIncludeItem)) {
|
|
1093
|
-
return promiseAll(
|
|
1094
|
-
arrayExtendMapWithIndex(
|
|
1095
|
-
[shouldIncludeItem], array, predicate, index)).then(
|
|
1096
|
-
curry4(arrayFilterByConditions, array, result, index - 1, __))
|
|
1097
|
-
}
|
|
1098
|
-
if (shouldIncludeItem) {
|
|
1099
|
-
result[++resultIndex] = item
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return result
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
1049
|
const _filter = function (value, predicate) {
|
|
1106
1050
|
if (isArray(value)) {
|
|
1107
1051
|
return arrayFilter(value, predicate)
|
|
1108
1052
|
}
|
|
1109
|
-
if (typeof value == 'function') {
|
|
1110
|
-
if (isGeneratorFunction(value)) {
|
|
1111
|
-
return generatorFunctionFilter(value, predicate)
|
|
1112
|
-
}
|
|
1113
|
-
if (isAsyncGeneratorFunction(value)) {
|
|
1114
|
-
return asyncGeneratorFunctionFilter(value, predicate)
|
|
1115
|
-
}
|
|
1116
|
-
return reducerFilter(value, predicate)
|
|
1117
|
-
}
|
|
1118
1053
|
if (value == null) {
|
|
1119
1054
|
return value
|
|
1120
1055
|
}
|
|
@@ -1145,51 +1080,27 @@ const _filter = function (value, predicate) {
|
|
|
1145
1080
|
|
|
1146
1081
|
const filter = function (...args) {
|
|
1147
1082
|
const predicate = args.pop()
|
|
1148
|
-
if (args.length
|
|
1149
|
-
return _filter
|
|
1083
|
+
if (args.length == 0) {
|
|
1084
|
+
return curry2(_filter, __, predicate)
|
|
1150
1085
|
}
|
|
1151
|
-
return
|
|
1086
|
+
return _filter(args[0], predicate)
|
|
1152
1087
|
}
|
|
1153
1088
|
|
|
1154
|
-
|
|
1155
|
-
if (isArray(value)) {
|
|
1156
|
-
return arrayFilterWithIndex(value, predicate)
|
|
1157
|
-
}
|
|
1158
|
-
throw new TypeError(`${value} is not an Array`)
|
|
1159
|
-
}
|
|
1089
|
+
const objectValues = Object.values
|
|
1160
1090
|
|
|
1161
|
-
|
|
1162
|
-
const curryArgs3ResolveArgs0 = (
|
|
1163
|
-
baseFunc, arg1, arg2,
|
|
1164
|
-
) => function args0Resolver(...args) {
|
|
1165
|
-
return baseFunc(args, arg1, arg2)
|
|
1166
|
-
}
|
|
1091
|
+
const objectProto = Object.prototype
|
|
1167
1092
|
|
|
1168
|
-
|
|
1169
|
-
const curryArgs3ResolveArgs1 = (
|
|
1170
|
-
baseFunc, arg0, arg2,
|
|
1171
|
-
) => function arg1Resolver(...args) {
|
|
1172
|
-
return baseFunc(arg0, args, arg2)
|
|
1173
|
-
}
|
|
1093
|
+
const nativeObjectToString = objectProto.toString
|
|
1174
1094
|
|
|
1175
|
-
|
|
1176
|
-
const curryArgs3ResolveArgs2 = (
|
|
1177
|
-
baseFunc, arg0, arg1,
|
|
1178
|
-
) => function arg2Resolver(...args) {
|
|
1179
|
-
return baseFunc(arg0, arg1, args)
|
|
1180
|
-
}
|
|
1095
|
+
const objectToString = value => nativeObjectToString.call(value)
|
|
1181
1096
|
|
|
1182
|
-
const
|
|
1183
|
-
if (arg0 == __) {
|
|
1184
|
-
return curryArgs3ResolveArgs0(baseFunc, arg1, arg2)
|
|
1185
|
-
}
|
|
1186
|
-
if (arg1 == __) {
|
|
1187
|
-
return curryArgs3ResolveArgs1(baseFunc, arg0, arg2)
|
|
1188
|
-
}
|
|
1189
|
-
return curryArgs3ResolveArgs2(baseFunc, arg0, arg1)
|
|
1190
|
-
}
|
|
1097
|
+
const generatorFunctionTag = '[object GeneratorFunction]'
|
|
1191
1098
|
|
|
1192
|
-
const
|
|
1099
|
+
const isGeneratorFunction = value => objectToString(value) == generatorFunctionTag
|
|
1100
|
+
|
|
1101
|
+
const asyncGeneratorFunctionTag = '[object AsyncGeneratorFunction]'
|
|
1102
|
+
|
|
1103
|
+
const isAsyncGeneratorFunction = value => objectToString(value) == asyncGeneratorFunctionTag
|
|
1193
1104
|
|
|
1194
1105
|
const iteratorReduceAsync = async function (
|
|
1195
1106
|
iterator, reducer, result,
|
|
@@ -1326,13 +1237,6 @@ const curry5 = function (baseFunc, arg0, arg1, arg2, arg3, arg4) {
|
|
|
1326
1237
|
|
|
1327
1238
|
const objectKeys = Object.keys
|
|
1328
1239
|
|
|
1329
|
-
const objectGetFirstKey = function (object) {
|
|
1330
|
-
for (const key in object) {
|
|
1331
|
-
return key
|
|
1332
|
-
}
|
|
1333
|
-
return undefined
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
1240
|
const objectReduceAsync = async function (object, reducer, result, keys, index) {
|
|
1337
1241
|
const keysLength = keys.length
|
|
1338
1242
|
while (++index < keysLength) {
|
|
@@ -1393,18 +1297,6 @@ const mapReduce = function (map, reducer, result) {
|
|
|
1393
1297
|
return result
|
|
1394
1298
|
}
|
|
1395
1299
|
|
|
1396
|
-
const generatorFunctionReduce = (
|
|
1397
|
-
generatorFunction, reducer, result,
|
|
1398
|
-
) => funcConcatSync(
|
|
1399
|
-
generatorFunction,
|
|
1400
|
-
curry3(iteratorReduce, __, reducer, result))
|
|
1401
|
-
|
|
1402
|
-
const asyncGeneratorFunctionReduce = (
|
|
1403
|
-
asyncGeneratorFunction, reducer, result,
|
|
1404
|
-
) => funcConcatSync(
|
|
1405
|
-
asyncGeneratorFunction,
|
|
1406
|
-
curry3(asyncIteratorReduce, __, reducer, result))
|
|
1407
|
-
|
|
1408
1300
|
const reducerConcat = (
|
|
1409
1301
|
reducerA, reducerB,
|
|
1410
1302
|
) => function pipedReducer(result, item) {
|
|
@@ -1414,26 +1306,10 @@ const reducerConcat = (
|
|
|
1414
1306
|
: reducerB(intermediate, item)
|
|
1415
1307
|
}
|
|
1416
1308
|
|
|
1417
|
-
const genericReduce = function (
|
|
1418
|
-
const collection = args[0]
|
|
1309
|
+
const genericReduce = function (collection, reducer, result) {
|
|
1419
1310
|
if (isArray(collection)) {
|
|
1420
1311
|
return arrayReduce(collection, reducer, result)
|
|
1421
1312
|
}
|
|
1422
|
-
if (typeof collection == 'function') {
|
|
1423
|
-
if (isGeneratorFunction(collection)) {
|
|
1424
|
-
return generatorFunctionReduce(collection, reducer, result)
|
|
1425
|
-
}
|
|
1426
|
-
if (isAsyncGeneratorFunction(collection)) {
|
|
1427
|
-
return asyncGeneratorFunctionReduce(collection, reducer, result)
|
|
1428
|
-
}
|
|
1429
|
-
return curryArgs3(
|
|
1430
|
-
genericReduce,
|
|
1431
|
-
__,
|
|
1432
|
-
args.length == 1
|
|
1433
|
-
? reducerConcat(reducer, collection)
|
|
1434
|
-
: args.reduce(reducerConcat, reducer),
|
|
1435
|
-
result)
|
|
1436
|
-
}
|
|
1437
1313
|
if (collection == null) {
|
|
1438
1314
|
return result === undefined
|
|
1439
1315
|
? curry2(reducer, collection, __)
|
|
@@ -1468,38 +1344,33 @@ const genericReduce = function (args, reducer, result) {
|
|
|
1468
1344
|
: reducer(result, collection)
|
|
1469
1345
|
}
|
|
1470
1346
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
return genericReduce([args[0]], reducer, initialValue)
|
|
1347
|
+
// _reduce(collection any, reducer function, initialValue function|any) -> Promise
|
|
1348
|
+
const _reduce = function (collection, reducer, initialValue) {
|
|
1349
|
+
if (typeof initialValue == 'function') {
|
|
1350
|
+
const actualInitialValue = initialValue(collection)
|
|
1351
|
+
return isPromise(actualInitialValue)
|
|
1352
|
+
? actualInitialValue.then(curry3(genericReduce, collection, reducer, __))
|
|
1353
|
+
: genericReduce(collection, reducer, actualInitialValue)
|
|
1479
1354
|
}
|
|
1355
|
+
return isPromise(initialValue)
|
|
1356
|
+
? initialValue.then(curry3(genericReduce, collection, reducer, __))
|
|
1357
|
+
: genericReduce(collection, reducer, initialValue)
|
|
1358
|
+
}
|
|
1480
1359
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
return isPromise(result)
|
|
1488
|
-
? result.then(curry3(genericReduce, args, reducer, __))
|
|
1489
|
-
: genericReduce(args, reducer, result)
|
|
1490
|
-
}
|
|
1360
|
+
const reduce = function (...args) {
|
|
1361
|
+
if (typeof args[0] == 'function') {
|
|
1362
|
+
return curry3(_reduce, __, args[0], args[1])
|
|
1363
|
+
}
|
|
1364
|
+
if (isPromise(args[0])) {
|
|
1365
|
+
return args[0].then(curry3(_reduce, __, args[1], args[2]))
|
|
1491
1366
|
}
|
|
1492
|
-
return
|
|
1367
|
+
return _reduce(args[0], args[1], args[2])
|
|
1493
1368
|
}
|
|
1494
1369
|
|
|
1495
1370
|
const isBinary = ArrayBuffer.isView
|
|
1496
1371
|
|
|
1497
1372
|
const add = (a, b) => a + b
|
|
1498
1373
|
|
|
1499
|
-
const isArrayLike = function (value) {
|
|
1500
|
-
return value != null && value.length > 0
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
1374
|
const _arrayExtend = function (array, values) {
|
|
1504
1375
|
const arrayLength = array.length,
|
|
1505
1376
|
valuesLength = values.length
|
|
@@ -1511,7 +1382,7 @@ const _arrayExtend = function (array, values) {
|
|
|
1511
1382
|
}
|
|
1512
1383
|
|
|
1513
1384
|
const arrayExtend = function (array, values) {
|
|
1514
|
-
if (
|
|
1385
|
+
if (isArray(values) || isBinary(values)) {
|
|
1515
1386
|
return _arrayExtend(array, values)
|
|
1516
1387
|
}
|
|
1517
1388
|
array.push(values)
|
|
@@ -1582,57 +1453,66 @@ const callConcat = function (object, values) {
|
|
|
1582
1453
|
return object.concat(values)
|
|
1583
1454
|
}
|
|
1584
1455
|
|
|
1585
|
-
const identityTransform = function (
|
|
1586
|
-
const nil = genericReduce(
|
|
1456
|
+
const identityTransform = function (collection, transducer, result) {
|
|
1457
|
+
const nil = genericReduce(collection, transducer(noop), null)
|
|
1587
1458
|
return isPromise(nil) ? nil.then(always(result)) : result
|
|
1588
1459
|
}
|
|
1589
1460
|
|
|
1590
|
-
const genericTransform = function (
|
|
1461
|
+
const genericTransform = function (collection, transducer, result) {
|
|
1591
1462
|
if (isArray(result)) {
|
|
1592
|
-
return genericReduce(
|
|
1463
|
+
return genericReduce(collection, transducer(arrayExtend), result)
|
|
1593
1464
|
}
|
|
1594
1465
|
if (isBinary(result)) {
|
|
1595
|
-
const intermediateArray = genericReduce(
|
|
1466
|
+
const intermediateArray = genericReduce(collection, transducer(arrayExtend), [])
|
|
1596
1467
|
return isPromise(intermediateArray)
|
|
1597
1468
|
? intermediateArray.then(curry2(binaryExtend, result, __))
|
|
1598
1469
|
: binaryExtend(result, intermediateArray)
|
|
1599
1470
|
}
|
|
1600
1471
|
if (result == null) {
|
|
1601
|
-
return identityTransform(
|
|
1472
|
+
return identityTransform(collection, transducer, result)
|
|
1602
1473
|
}
|
|
1603
1474
|
|
|
1604
1475
|
const resultConstructor = result.constructor
|
|
1605
1476
|
if (typeof result == 'string' || resultConstructor == String) {
|
|
1606
1477
|
// TODO: use array + join over adding
|
|
1607
|
-
return genericReduce(
|
|
1478
|
+
return genericReduce(collection, transducer(add), result)
|
|
1608
1479
|
}
|
|
1609
1480
|
if (typeof result.concat == 'function') {
|
|
1610
|
-
return genericReduce(
|
|
1481
|
+
return genericReduce(collection, transducer(callConcat), result)
|
|
1611
1482
|
}
|
|
1612
1483
|
if (typeof result.write == 'function') {
|
|
1613
|
-
return genericReduce(
|
|
1484
|
+
return genericReduce(collection, transducer(streamExtend), result)
|
|
1614
1485
|
}
|
|
1615
1486
|
if (resultConstructor == Set) {
|
|
1616
|
-
return genericReduce(
|
|
1487
|
+
return genericReduce(collection, transducer(setExtend), result)
|
|
1617
1488
|
}
|
|
1618
1489
|
if (resultConstructor == Object) {
|
|
1619
|
-
return genericReduce(
|
|
1490
|
+
return genericReduce(collection, transducer(objectAssign), result)
|
|
1620
1491
|
}
|
|
1621
|
-
return identityTransform(
|
|
1492
|
+
return identityTransform(collection, transducer, result)
|
|
1622
1493
|
}
|
|
1623
1494
|
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1495
|
+
// _transform(collection any, transducer function, initialValue function|any) -> Promise
|
|
1496
|
+
const _transform = function (collection, transducer, initialValue) {
|
|
1497
|
+
if (typeof initialValue == 'function') {
|
|
1498
|
+
const actualInitialValue = initialValue(collection)
|
|
1499
|
+
return isPromise(actualInitialValue)
|
|
1500
|
+
? actualInitialValue.then(curry3(genericTransform, collection, transducer, __))
|
|
1501
|
+
: genericTransform(collection, transducer, actualInitialValue)
|
|
1502
|
+
}
|
|
1503
|
+
return isPromise(initialValue)
|
|
1504
|
+
? initialValue.then(curry3(genericTransform, collection, transducer, __))
|
|
1505
|
+
: genericTransform(collection, transducer, initialValue)
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
const transform = function (...args) {
|
|
1509
|
+
if (typeof args[0] == 'function') {
|
|
1510
|
+
return curry3(_transform, __, args[0], args[1])
|
|
1632
1511
|
}
|
|
1633
|
-
|
|
1634
|
-
return
|
|
1512
|
+
if (isPromise(args[0])) {
|
|
1513
|
+
return args[0].then(curry3(_transform, __, args[1], args[2]))
|
|
1635
1514
|
}
|
|
1515
|
+
return _transform(args[0], args[1], args[2])
|
|
1636
1516
|
}
|
|
1637
1517
|
|
|
1638
1518
|
const arrayPush = function (array, value) {
|
|
@@ -1659,7 +1539,7 @@ const FlatMappingIterator = function (iterator, flatMapper) {
|
|
|
1659
1539
|
return iteration
|
|
1660
1540
|
}
|
|
1661
1541
|
const monadAsArray = genericReduce(
|
|
1662
|
-
|
|
1542
|
+
flatMapper(iteration.value),
|
|
1663
1543
|
arrayPush,
|
|
1664
1544
|
[]) // this will always have at least one item
|
|
1665
1545
|
if (monadAsArray.length > 1) {
|
|
@@ -1703,12 +1583,12 @@ const FlatMappingAsyncIterator = function (asyncIterator, flatMapper) {
|
|
|
1703
1583
|
} else {
|
|
1704
1584
|
const monad = flatMapper(value)
|
|
1705
1585
|
if (isPromise(monad)) {
|
|
1706
|
-
const bufferLoading =
|
|
1707
|
-
|
|
1586
|
+
const bufferLoading =
|
|
1587
|
+
monad.then(curry3(genericReduce, __, arrayPush, buffer))
|
|
1708
1588
|
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
1709
1589
|
promises.add(promise)
|
|
1710
1590
|
} else {
|
|
1711
|
-
const bufferLoading = genericReduce(
|
|
1591
|
+
const bufferLoading = genericReduce(monad, arrayPush, buffer)
|
|
1712
1592
|
if (isPromise(bufferLoading)) {
|
|
1713
1593
|
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
1714
1594
|
promises.add(promise)
|
|
@@ -1732,6 +1612,12 @@ const getArg1 = (arg0, arg1) => arg1
|
|
|
1732
1612
|
|
|
1733
1613
|
const identity = value => value
|
|
1734
1614
|
|
|
1615
|
+
const funcConcatSync = (
|
|
1616
|
+
funcA, funcB,
|
|
1617
|
+
) => function pipedFunction(...args) {
|
|
1618
|
+
return funcB(funcA(...args))
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1735
1621
|
const asyncIteratorForEach = async function (asyncIterator, callback) {
|
|
1736
1622
|
const promises = []
|
|
1737
1623
|
for await (const item of asyncIterator) {
|
|
@@ -1911,149 +1797,17 @@ const arrayFlattenToString = funcConcat(
|
|
|
1911
1797
|
arrayFlatten,
|
|
1912
1798
|
curry2(arrayJoin, __, ''))
|
|
1913
1799
|
|
|
1914
|
-
const stringFlatMap = function (string, flatMapper) {
|
|
1915
|
-
const monadArray = arrayMap(string, flatMapper)
|
|
1916
|
-
return isPromise(monadArray)
|
|
1917
|
-
? monadArray.then(arrayFlattenToString)
|
|
1918
|
-
: arrayFlattenToString(monadArray)
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
const streamWrite = function (stream, chunk, encoding, callback) {
|
|
1922
|
-
stream.write(chunk, encoding, callback)
|
|
1923
|
-
return stream
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
const streamFlatExtend = async function (stream, item) {
|
|
1927
|
-
const resultStreamWrite = curry2(streamWrite, stream, __),
|
|
1928
|
-
// resultStreamWriteReducer = (_, subItem) => stream.write(subItem),
|
|
1929
|
-
resultStreamWriteReducer = funcConcatSync(getArg1, resultStreamWrite),
|
|
1930
|
-
promises = []
|
|
1931
|
-
if (isArray(item)) {
|
|
1932
|
-
const itemLength = item.length
|
|
1933
|
-
let itemIndex = -1
|
|
1934
|
-
while (++itemIndex < itemLength) {
|
|
1935
|
-
stream.write(item[itemIndex])
|
|
1936
|
-
}
|
|
1937
|
-
} else if (item == null) {
|
|
1938
|
-
stream.write(item)
|
|
1939
|
-
} else if (typeof item[symbolIterator] == 'function') {
|
|
1940
|
-
for (const subItem of item) {
|
|
1941
|
-
stream.write(subItem)
|
|
1942
|
-
}
|
|
1943
|
-
} else if (typeof item[symbolAsyncIterator] == 'function') {
|
|
1944
|
-
promises.push(
|
|
1945
|
-
asyncIteratorForEach(item[symbolAsyncIterator](), resultStreamWrite))
|
|
1946
|
-
} else if (typeof item.chain == 'function') {
|
|
1947
|
-
const monadValue = item.chain(identity)
|
|
1948
|
-
isPromise(monadValue)
|
|
1949
|
-
? promises.push(monadValue.then(resultStreamWrite))
|
|
1950
|
-
: stream.write(monadValue)
|
|
1951
|
-
} else if (typeof item.flatMap == 'function') {
|
|
1952
|
-
const monadValue = item.flatMap(identity)
|
|
1953
|
-
isPromise(monadValue)
|
|
1954
|
-
? promises.push(monadValue.then(resultStreamWrite))
|
|
1955
|
-
: stream.write(monadValue)
|
|
1956
|
-
} else if (typeof item.reduce == 'function') {
|
|
1957
|
-
const folded = item.reduce(resultStreamWriteReducer, null)
|
|
1958
|
-
isPromise(folded) && promises.push(folded)
|
|
1959
|
-
} else if (item.constructor == Object) {
|
|
1960
|
-
for (const key in item) {
|
|
1961
|
-
stream.write(item[key])
|
|
1962
|
-
}
|
|
1963
|
-
} else {
|
|
1964
|
-
stream.write(item)
|
|
1965
|
-
}
|
|
1966
|
-
return promises.length == 0
|
|
1967
|
-
? stream
|
|
1968
|
-
: promiseAll(promises).then(always(stream))
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
const streamFlatMap = async function (stream, flatMapper) {
|
|
1972
|
-
const promises = new Set()
|
|
1973
|
-
for await (const item of stream) {
|
|
1974
|
-
const monad = flatMapper(item)
|
|
1975
|
-
if (isPromise(monad)) {
|
|
1976
|
-
const selfDeletingPromise = monad.then(
|
|
1977
|
-
curry2(streamFlatExtend, stream, __)).then(
|
|
1978
|
-
() => promises.delete(selfDeletingPromise))
|
|
1979
|
-
promises.add(selfDeletingPromise)
|
|
1980
|
-
} else {
|
|
1981
|
-
const streamFlatteningOperation = streamFlatExtend(stream, monad)
|
|
1982
|
-
if (isPromise(streamFlatteningOperation)) {
|
|
1983
|
-
const selfDeletingPromise = streamFlatteningOperation.then(
|
|
1984
|
-
() => promises.delete(selfDeletingPromise))
|
|
1985
|
-
promises.add(selfDeletingPromise)
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
await promiseAll(promises)
|
|
1990
|
-
return stream
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
const arrayJoinToBinary = function (array, init) {
|
|
1994
|
-
const length = array.length
|
|
1995
|
-
let index = -1,
|
|
1996
|
-
result = init
|
|
1997
|
-
while (++index < length) {
|
|
1998
|
-
result = binaryExtend(result, array[index])
|
|
1999
|
-
}
|
|
2000
|
-
return result
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
const arrayFlattenToBinary = function (array, result) {
|
|
2004
|
-
const flattened = arrayFlatten(array)
|
|
2005
|
-
return isPromise(flattened)
|
|
2006
|
-
? flattened.then(curry2(arrayJoinToBinary, __, result))
|
|
2007
|
-
: arrayJoinToBinary(flattened, result)
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
const binaryFlatMap = function (binary, flatMapper) {
|
|
2011
|
-
const monadArray = arrayMap(binary, flatMapper),
|
|
2012
|
-
result = globalThisHasBuffer && binary.constructor == Buffer
|
|
2013
|
-
? bufferAlloc(0)
|
|
2014
|
-
: new binary.constructor(0)
|
|
2015
|
-
return isPromise(monadArray)
|
|
2016
|
-
? monadArray.then(curry2(arrayFlattenToBinary, __, result))
|
|
2017
|
-
: arrayFlattenToBinary(monadArray, result)
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
const reducerFlatMap = (
|
|
2021
|
-
reducer, flatMapper,
|
|
2022
|
-
) => function flatMappingReducer(result, value) {
|
|
2023
|
-
const monad = flatMapper(value)
|
|
2024
|
-
return isPromise(monad)
|
|
2025
|
-
? monad.then(curryArgs3(genericReduce, __, reducer, result))
|
|
2026
|
-
: genericReduce([monad], reducer, result)
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
const generatorFunctionFlatMap = (
|
|
2030
|
-
generatorFunction, flatMapper,
|
|
2031
|
-
) => function* flatMappingGeneratorFunction(...args) {
|
|
2032
|
-
yield* FlatMappingIterator(generatorFunction(...args), flatMapper)
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
const asyncGeneratorFunctionFlatMap = (
|
|
2036
|
-
asyncGeneratorFunction, flatMapper,
|
|
2037
|
-
) => async function* flatMappingAsyncGeneratorFunction(...args) {
|
|
2038
|
-
yield* FlatMappingAsyncIterator(asyncGeneratorFunction(...args), flatMapper)
|
|
1800
|
+
const stringFlatMap = function (string, flatMapper) {
|
|
1801
|
+
const monadArray = arrayMap(string, flatMapper)
|
|
1802
|
+
return isPromise(monadArray)
|
|
1803
|
+
? monadArray.then(arrayFlattenToString)
|
|
1804
|
+
: arrayFlattenToString(monadArray)
|
|
2039
1805
|
}
|
|
2040
1806
|
|
|
2041
|
-
const
|
|
1807
|
+
const _flatMap = function (value, flatMapper) {
|
|
2042
1808
|
if (isArray(value)) {
|
|
2043
1809
|
return arrayFlatMap(value, flatMapper)
|
|
2044
1810
|
}
|
|
2045
|
-
if (typeof value == 'function') {
|
|
2046
|
-
if (isGeneratorFunction(value)) {
|
|
2047
|
-
return generatorFunctionFlatMap(value, flatMapper)
|
|
2048
|
-
}
|
|
2049
|
-
if (isAsyncGeneratorFunction(value)) {
|
|
2050
|
-
return asyncGeneratorFunctionFlatMap(value, flatMapper)
|
|
2051
|
-
}
|
|
2052
|
-
return reducerFlatMap(value, flatMapper)
|
|
2053
|
-
}
|
|
2054
|
-
if (isBinary(value)) {
|
|
2055
|
-
return binaryFlatMap(value, flatMapper)
|
|
2056
|
-
}
|
|
2057
1811
|
if (value == null) {
|
|
2058
1812
|
return flatMapper(value)
|
|
2059
1813
|
}
|
|
@@ -2072,12 +1826,6 @@ const flatMap = flatMapper => function flatMapping(value) {
|
|
|
2072
1826
|
if (typeof value.flatMap == 'function') {
|
|
2073
1827
|
return value.flatMap(flatMapper)
|
|
2074
1828
|
}
|
|
2075
|
-
if (
|
|
2076
|
-
typeof value[symbolAsyncIterator] == 'function'
|
|
2077
|
-
&& typeof value.write == 'function'
|
|
2078
|
-
) {
|
|
2079
|
-
return streamFlatMap(value, flatMapper)
|
|
2080
|
-
}
|
|
2081
1829
|
const valueConstructor = value.constructor
|
|
2082
1830
|
if (valueConstructor == Object) {
|
|
2083
1831
|
return objectFlatMap(value, flatMapper)
|
|
@@ -2091,12 +1839,93 @@ const flatMap = flatMapper => function flatMapping(value) {
|
|
|
2091
1839
|
return flatMapper(value)
|
|
2092
1840
|
}
|
|
2093
1841
|
|
|
1842
|
+
const flatMap = (...args) => {
|
|
1843
|
+
const flatMapper = args.pop()
|
|
1844
|
+
if (args.length == 0) {
|
|
1845
|
+
return curry2(_flatMap, __, flatMapper)
|
|
1846
|
+
}
|
|
1847
|
+
const collection = args[0]
|
|
1848
|
+
return isPromise(collection)
|
|
1849
|
+
? collection.then(curry2(_flatMap, __, flatMapper))
|
|
1850
|
+
: _flatMap(args[0], flatMapper)
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
const arrayForEach = function (array, callback) {
|
|
1854
|
+
const length = array.length,
|
|
1855
|
+
promises = []
|
|
1856
|
+
let index = -1
|
|
1857
|
+
while (++index < length) {
|
|
1858
|
+
const operation = callback(array[index])
|
|
1859
|
+
if (isPromise(operation)) {
|
|
1860
|
+
promises.push(operation)
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
return promises.length == 0 ? array : promiseAll(promises).then(always(array))
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
const objectForEach = function (object, callback) {
|
|
1867
|
+
const promises = []
|
|
1868
|
+
for (const key in object) {
|
|
1869
|
+
const operation = callback(object[key])
|
|
1870
|
+
if (isPromise(operation)) {
|
|
1871
|
+
promises.push(operation)
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
return promises.length == 0 ? object : promiseAll(promises).then(always(object))
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
const iteratorForEach = function (iterator, callback) {
|
|
1878
|
+
const promises = []
|
|
1879
|
+
for (const item of iterator) {
|
|
1880
|
+
const operation = callback(item)
|
|
1881
|
+
if (isPromise(operation)) {
|
|
1882
|
+
promises.push(operation)
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
return promises.length == 0 ? iterator : promiseAll(promises).then(always(iterator))
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// type Collection = Array|Iterable|AsyncIterable|{ forEach: function }|Object
|
|
1889
|
+
// _forEach(collection Collection, callback function) -> collection Collection
|
|
1890
|
+
const _forEach = function (collection, callback) {
|
|
1891
|
+
if (isArray(collection)) {
|
|
1892
|
+
return arrayForEach(collection, callback)
|
|
1893
|
+
}
|
|
1894
|
+
if (collection == null) {
|
|
1895
|
+
return collection
|
|
1896
|
+
}
|
|
1897
|
+
if (typeof collection.forEach == 'function') {
|
|
1898
|
+
return collection.forEach(callback)
|
|
1899
|
+
}
|
|
1900
|
+
if (typeof collection[symbolIterator] == 'function') {
|
|
1901
|
+
return iteratorForEach(collection[symbolIterator](), callback)
|
|
1902
|
+
}
|
|
1903
|
+
if (typeof collection[symbolAsyncIterator] == 'function') {
|
|
1904
|
+
return asyncIteratorForEach(collection[symbolAsyncIterator](), callback)
|
|
1905
|
+
}
|
|
1906
|
+
if (collection.constructor == Object) {
|
|
1907
|
+
return objectForEach(collection, callback)
|
|
1908
|
+
}
|
|
1909
|
+
return collection
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
const forEach = function (...args) {
|
|
1913
|
+
const callback = args.pop()
|
|
1914
|
+
if (args.length == 0) {
|
|
1915
|
+
return curry2(_forEach, __, callback)
|
|
1916
|
+
}
|
|
1917
|
+
const collection = args[0]
|
|
1918
|
+
return isPromise(collection)
|
|
1919
|
+
? collection.then(curry2(_forEach, __, callback))
|
|
1920
|
+
: _forEach(collection, callback)
|
|
1921
|
+
}
|
|
1922
|
+
|
|
2094
1923
|
const SelfReferencingPromise = function (basePromise) {
|
|
2095
1924
|
const promise = basePromise.then(res => [res, promise])
|
|
2096
1925
|
return promise
|
|
2097
1926
|
}
|
|
2098
1927
|
|
|
2099
|
-
const
|
|
1928
|
+
const asyncArraySome = async function (
|
|
2100
1929
|
array, predicate, index, promisesInFlight,
|
|
2101
1930
|
) {
|
|
2102
1931
|
const length = array.length
|
|
@@ -2119,13 +1948,13 @@ const asyncArrayAny = async function (
|
|
|
2119
1948
|
return false
|
|
2120
1949
|
}
|
|
2121
1950
|
|
|
2122
|
-
const
|
|
1951
|
+
const arraySome = function (array, predicate) {
|
|
2123
1952
|
const length = array.length
|
|
2124
1953
|
let index = -1
|
|
2125
1954
|
while (++index < length) {
|
|
2126
1955
|
const predication = predicate(array[index])
|
|
2127
1956
|
if (isPromise(predication)) {
|
|
2128
|
-
return
|
|
1957
|
+
return asyncArraySome(
|
|
2129
1958
|
array, predicate, index, new Set([SelfReferencingPromise(predication)]))
|
|
2130
1959
|
}
|
|
2131
1960
|
if (predication) {
|
|
@@ -2135,7 +1964,7 @@ const arrayAny = function (array, predicate) {
|
|
|
2135
1964
|
return false
|
|
2136
1965
|
}
|
|
2137
1966
|
|
|
2138
|
-
const
|
|
1967
|
+
const asyncIteratorSome = async function (
|
|
2139
1968
|
iterator, predicate, promisesInFlight, maxConcurrency = 20,
|
|
2140
1969
|
) {
|
|
2141
1970
|
let iteration = iterator.next()
|
|
@@ -2172,11 +2001,11 @@ const asyncIteratorAny = async function (
|
|
|
2172
2001
|
return false
|
|
2173
2002
|
}
|
|
2174
2003
|
|
|
2175
|
-
const
|
|
2004
|
+
const iteratorSome = function (iterator, predicate) {
|
|
2176
2005
|
for (const item of iterator) {
|
|
2177
2006
|
const predication = predicate(item)
|
|
2178
2007
|
if (isPromise(predication)) {
|
|
2179
|
-
return
|
|
2008
|
+
return asyncIteratorSome(
|
|
2180
2009
|
iterator, predicate, new Set([SelfReferencingPromise(predication)]))
|
|
2181
2010
|
}
|
|
2182
2011
|
if (predication) {
|
|
@@ -2190,35 +2019,52 @@ const reducerAnySync = predicate => function anyReducer(result, item) {
|
|
|
2190
2019
|
return result ? true : predicate(item)
|
|
2191
2020
|
}
|
|
2192
2021
|
|
|
2193
|
-
const
|
|
2022
|
+
const reducerSome = predicate => function anyReducer(result, item) {
|
|
2194
2023
|
return result === true ? result
|
|
2195
2024
|
: isPromise(result) ? result.then(curry2(reducerAnySync(predicate), __, item))
|
|
2196
2025
|
: result ? true : predicate(item)
|
|
2197
2026
|
}
|
|
2198
2027
|
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2028
|
+
// _some(collection Array|Iterable|AsyncIterable|{ reduce: function }|Object, predicate function) -> Promise|boolean
|
|
2029
|
+
const _some = function (collection, predicate) {
|
|
2030
|
+
if (isArray(collection)) {
|
|
2031
|
+
return arraySome(collection, predicate)
|
|
2202
2032
|
}
|
|
2203
|
-
if (
|
|
2204
|
-
return predicate(
|
|
2033
|
+
if (collection == null) {
|
|
2034
|
+
return predicate(collection)
|
|
2205
2035
|
}
|
|
2206
|
-
if (typeof
|
|
2207
|
-
return
|
|
2036
|
+
if (typeof collection[symbolIterator] == 'function') {
|
|
2037
|
+
return iteratorSome(collection[symbolIterator](), predicate)
|
|
2208
2038
|
}
|
|
2209
|
-
if (typeof
|
|
2210
|
-
return
|
|
2039
|
+
if (typeof collection[symbolAsyncIterator] == 'function') {
|
|
2040
|
+
return asyncIteratorSome(
|
|
2041
|
+
collection[symbolAsyncIterator](), predicate, new Set()
|
|
2042
|
+
)
|
|
2043
|
+
}
|
|
2044
|
+
if (typeof collection.reduce == 'function') {
|
|
2045
|
+
return collection.reduce(reducerSome(predicate), false)
|
|
2211
2046
|
}
|
|
2212
|
-
if (
|
|
2213
|
-
return
|
|
2047
|
+
if (collection.constructor == Object) {
|
|
2048
|
+
return arraySome(objectValues(collection), predicate)
|
|
2214
2049
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2050
|
+
return predicate(collection)
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
const some = function (...args) {
|
|
2054
|
+
const predicate = args.pop()
|
|
2055
|
+
if (args.length == 0) {
|
|
2056
|
+
return curry2(_some, __, predicate)
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
const collection = args[0]
|
|
2060
|
+
if (isPromise(collection)) {
|
|
2061
|
+
return collection.then(curry2(_some, __, predicate))
|
|
2217
2062
|
}
|
|
2218
|
-
|
|
2063
|
+
|
|
2064
|
+
return _some(collection, predicate)
|
|
2219
2065
|
}
|
|
2220
2066
|
|
|
2221
|
-
const
|
|
2067
|
+
const arrayEvery = function (array, predicate) {
|
|
2222
2068
|
const arrayLength = array.length,
|
|
2223
2069
|
promises = []
|
|
2224
2070
|
let index = -1
|
|
@@ -2235,7 +2081,7 @@ const arrayAll = function (array, predicate) {
|
|
|
2235
2081
|
: promiseAll(promises).then(curry3(callPropUnary, __, 'every', Boolean))
|
|
2236
2082
|
}
|
|
2237
2083
|
|
|
2238
|
-
const
|
|
2084
|
+
const iteratorEvery = function (iterator, predicate) {
|
|
2239
2085
|
const promises = []
|
|
2240
2086
|
for (const item of iterator) {
|
|
2241
2087
|
const predication = predicate(item)
|
|
@@ -2250,7 +2096,7 @@ const iteratorAll = function (iterator, predicate) {
|
|
|
2250
2096
|
: promiseAll(promises).then(curry3(callPropUnary, __, 'every', Boolean))
|
|
2251
2097
|
}
|
|
2252
2098
|
|
|
2253
|
-
const
|
|
2099
|
+
const asyncIteratorEvery = async function (
|
|
2254
2100
|
asyncIterator, predicate, promisesInFlight, maxConcurrency = 20,
|
|
2255
2101
|
) {
|
|
2256
2102
|
let iteration = await asyncIterator.next()
|
|
@@ -2283,45 +2129,62 @@ const asyncIteratorAll = async function (
|
|
|
2283
2129
|
|
|
2284
2130
|
const reducerAllSync = (predicate, result, item) => result ? predicate(item) : false
|
|
2285
2131
|
|
|
2286
|
-
const
|
|
2132
|
+
const reducerEvery = predicate => function allReducer(result, item) {
|
|
2287
2133
|
return result === false ? false
|
|
2288
2134
|
: isPromise(result) ? result.then(
|
|
2289
2135
|
curry3(reducerAllSync, predicate, __, item))
|
|
2290
2136
|
: result ? predicate(item) : false
|
|
2291
2137
|
}
|
|
2292
2138
|
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2139
|
+
// _every(collection Array|Iterable|AsyncIterable|{ reduce: function }|Object, predicate function) -> Promise|boolean
|
|
2140
|
+
const _every = function (collection, predicate) {
|
|
2141
|
+
if (isArray(collection)) {
|
|
2142
|
+
return arrayEvery(collection, predicate)
|
|
2296
2143
|
}
|
|
2297
|
-
if (
|
|
2298
|
-
return predicate(
|
|
2144
|
+
if (collection == null) {
|
|
2145
|
+
return predicate(collection)
|
|
2299
2146
|
}
|
|
2300
2147
|
|
|
2301
|
-
if (typeof
|
|
2302
|
-
return
|
|
2148
|
+
if (typeof collection[symbolIterator] == 'function') {
|
|
2149
|
+
return iteratorEvery(collection[symbolIterator](), predicate)
|
|
2303
2150
|
}
|
|
2304
|
-
if (typeof
|
|
2305
|
-
return
|
|
2151
|
+
if (typeof collection[symbolAsyncIterator] == 'function') {
|
|
2152
|
+
return asyncIteratorEvery(
|
|
2153
|
+
collection[symbolAsyncIterator](), predicate, new Set()
|
|
2154
|
+
)
|
|
2306
2155
|
}
|
|
2307
|
-
if (typeof
|
|
2308
|
-
return
|
|
2156
|
+
if (typeof collection.reduce == 'function') {
|
|
2157
|
+
return collection.reduce(reducerEvery(predicate), true)
|
|
2309
2158
|
}
|
|
2310
|
-
if (
|
|
2311
|
-
return
|
|
2159
|
+
if (collection.constructor == Object) {
|
|
2160
|
+
return arrayEvery(objectValues(collection), predicate)
|
|
2161
|
+
}
|
|
2162
|
+
return predicate(collection)
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
const every = function (...args) {
|
|
2166
|
+
const predicate = args.pop()
|
|
2167
|
+
if (args.length == 0) {
|
|
2168
|
+
return curry2(_every, __, predicate)
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
const collection = args[0]
|
|
2172
|
+
if (isPromise(collection)) {
|
|
2173
|
+
return collection.then(curry2(_every, __, predicate))
|
|
2312
2174
|
}
|
|
2313
|
-
|
|
2175
|
+
|
|
2176
|
+
return _every(collection, predicate)
|
|
2314
2177
|
}
|
|
2315
2178
|
|
|
2316
|
-
const
|
|
2179
|
+
const areAllValuesTruthy = function (predicates, index) {
|
|
2317
2180
|
const length = predicates.length
|
|
2318
2181
|
while (++index < length) {
|
|
2319
|
-
|
|
2182
|
+
const predicate = predicates[index]
|
|
2320
2183
|
if (isPromise(predicate)) {
|
|
2321
2184
|
return predicate.then(curry3(
|
|
2322
2185
|
thunkConditional,
|
|
2323
2186
|
__,
|
|
2324
|
-
thunkify2(
|
|
2187
|
+
thunkify2(areAllValuesTruthy, predicates, index),
|
|
2325
2188
|
always(false),
|
|
2326
2189
|
))
|
|
2327
2190
|
}
|
|
@@ -2332,12 +2195,12 @@ const areAllNonfunctionsTruthy = function (predicates, index) {
|
|
|
2332
2195
|
return true
|
|
2333
2196
|
}
|
|
2334
2197
|
|
|
2335
|
-
const asyncArePredicatesAllTruthy = async function (
|
|
2198
|
+
const asyncArePredicatesAllTruthy = async function (args, predicates, index) {
|
|
2336
2199
|
const length = predicates.length
|
|
2337
2200
|
while (++index < length) {
|
|
2338
2201
|
let predicate = predicates[index]
|
|
2339
2202
|
if (typeof predicate == 'function') {
|
|
2340
|
-
predicate = predicate(
|
|
2203
|
+
predicate = predicate(...args)
|
|
2341
2204
|
}
|
|
2342
2205
|
if (isPromise(predicate)) {
|
|
2343
2206
|
predicate = await predicate
|
|
@@ -2349,39 +2212,53 @@ const asyncArePredicatesAllTruthy = async function (predicates, point, index) {
|
|
|
2349
2212
|
return true
|
|
2350
2213
|
}
|
|
2351
2214
|
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
return function arePredicatesAllTruthy(point) {
|
|
2357
|
-
const length = predicates.length
|
|
2358
|
-
let index = -1
|
|
2215
|
+
// areAllPredicatesTruthy(args Array, predicates Array<function>) -> Promise|boolean
|
|
2216
|
+
const areAllPredicatesTruthy = function (args, predicates) {
|
|
2217
|
+
const length = predicates.length
|
|
2218
|
+
let index = -1
|
|
2359
2219
|
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
}
|
|
2220
|
+
while (++index < length) {
|
|
2221
|
+
let predicate = predicates[index]
|
|
2222
|
+
if (typeof predicate == 'function') {
|
|
2223
|
+
predicate = predicate(...args)
|
|
2224
|
+
}
|
|
2225
|
+
if (isPromise(predicate)) {
|
|
2226
|
+
return predicate.then(curry3(
|
|
2227
|
+
thunkConditional,
|
|
2228
|
+
__,
|
|
2229
|
+
thunkify3(asyncArePredicatesAllTruthy, args, predicates, index),
|
|
2230
|
+
always(false),
|
|
2231
|
+
))
|
|
2232
|
+
}
|
|
2233
|
+
if (!predicate) {
|
|
2234
|
+
return false
|
|
2376
2235
|
}
|
|
2377
|
-
return true
|
|
2378
2236
|
}
|
|
2237
|
+
return true
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
const and = function (...args) {
|
|
2241
|
+
const predicatesOrValues = args.pop()
|
|
2242
|
+
if (areAllValuesNonfunctions(predicatesOrValues)) {
|
|
2243
|
+
return areAllValuesTruthy(predicatesOrValues, -1)
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
if (args.length == 0) {
|
|
2247
|
+
return curryArgs2(areAllPredicatesTruthy, __, predicatesOrValues)
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
if (areAnyValuesPromises(args)) {
|
|
2251
|
+
return promiseAll(args)
|
|
2252
|
+
.then(curry2(areAllPredicatesTruthy, __, predicatesOrValues))
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
return areAllPredicatesTruthy(args, predicatesOrValues)
|
|
2379
2256
|
}
|
|
2380
2257
|
|
|
2381
2258
|
const areAnyNonfunctionsTruthy = function (predicates, index) {
|
|
2382
2259
|
const length = predicates.length
|
|
2383
2260
|
while (++index < length) {
|
|
2384
|
-
|
|
2261
|
+
const predicate = predicates[index]
|
|
2385
2262
|
if (isPromise(predicate)) {
|
|
2386
2263
|
return predicate.then(curry3(
|
|
2387
2264
|
thunkConditional,
|
|
@@ -2397,14 +2274,13 @@ const areAnyNonfunctionsTruthy = function (predicates, index) {
|
|
|
2397
2274
|
return false
|
|
2398
2275
|
}
|
|
2399
2276
|
|
|
2400
|
-
const asyncAreAnyPredicatesTruthy = async function (
|
|
2277
|
+
const asyncAreAnyPredicatesTruthy = async function (args, predicates, index) {
|
|
2401
2278
|
const length = predicates.length
|
|
2402
2279
|
while (++index < length) {
|
|
2403
2280
|
let predicate = predicates[index]
|
|
2404
2281
|
if (typeof predicate == 'function') {
|
|
2405
|
-
predicate = predicate(
|
|
2282
|
+
predicate = predicate(...args)
|
|
2406
2283
|
}
|
|
2407
|
-
console.log('hey - or', predicate)
|
|
2408
2284
|
if (isPromise(predicate)) {
|
|
2409
2285
|
predicate = await predicate
|
|
2410
2286
|
}
|
|
@@ -2415,275 +2291,225 @@ const asyncAreAnyPredicatesTruthy = async function (predicates, point, index) {
|
|
|
2415
2291
|
return false
|
|
2416
2292
|
}
|
|
2417
2293
|
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
return function areAnyPredicatesTruthy(point) {
|
|
2423
|
-
const length = predicates.length
|
|
2424
|
-
let index = -1
|
|
2294
|
+
// areAnyPredicatesTruthy(args Array, predicates Array<function>) -> Promise|boolean
|
|
2295
|
+
const areAnyPredicatesTruthy = function (args, predicates) {
|
|
2296
|
+
const length = predicates.length
|
|
2297
|
+
let index = -1
|
|
2425
2298
|
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
}
|
|
2299
|
+
while (++index < length) {
|
|
2300
|
+
let predicate = predicates[index]
|
|
2301
|
+
if (typeof predicate == 'function') {
|
|
2302
|
+
predicate = predicate(...args)
|
|
2303
|
+
}
|
|
2304
|
+
if (isPromise(predicate)) {
|
|
2305
|
+
return predicate.then(curry3(
|
|
2306
|
+
thunkConditional,
|
|
2307
|
+
__,
|
|
2308
|
+
always(true),
|
|
2309
|
+
thunkify3(asyncAreAnyPredicatesTruthy, args, predicates, index),
|
|
2310
|
+
))
|
|
2311
|
+
}
|
|
2312
|
+
if (predicate) {
|
|
2313
|
+
return true
|
|
2442
2314
|
}
|
|
2443
|
-
return false
|
|
2444
2315
|
}
|
|
2316
|
+
return false
|
|
2445
2317
|
}
|
|
2446
2318
|
|
|
2447
|
-
|
|
2448
|
-
const
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
if (typeof funcOrValue == 'function') {
|
|
2452
|
-
return function logicalInverter(value) {
|
|
2453
|
-
const boolean = funcOrValue(value)
|
|
2454
|
-
return isPromise(boolean) ? boolean.then(_not) : !boolean
|
|
2455
|
-
}
|
|
2319
|
+
const or = function (...args) {
|
|
2320
|
+
const predicatesOrValues = args.pop()
|
|
2321
|
+
if (areAllValuesNonfunctions(predicatesOrValues)) {
|
|
2322
|
+
return areAnyNonfunctionsTruthy(predicatesOrValues, -1)
|
|
2456
2323
|
}
|
|
2457
|
-
return !funcOrValue
|
|
2458
|
-
}
|
|
2459
2324
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
}
|
|
2325
|
+
if (args.length == 0) {
|
|
2326
|
+
return curryArgs2(areAnyPredicatesTruthy, __, predicatesOrValues)
|
|
2327
|
+
}
|
|
2463
2328
|
|
|
2464
|
-
|
|
2329
|
+
if (areAnyValuesPromises(args)) {
|
|
2330
|
+
return promiseAll(args)
|
|
2331
|
+
.then(curry2(areAnyPredicatesTruthy, __, predicatesOrValues))
|
|
2332
|
+
}
|
|
2465
2333
|
|
|
2466
|
-
|
|
2467
|
-
return left === right || (left !== left && right !== right)
|
|
2334
|
+
return areAnyPredicatesTruthy(args, predicatesOrValues)
|
|
2468
2335
|
}
|
|
2469
2336
|
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
isRightResolver = typeof right == 'function'
|
|
2337
|
+
// negate(value boolean) -> inverse boolean
|
|
2338
|
+
const negate = value => !value
|
|
2473
2339
|
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
isRightPromise = isPromise(rightResolve)
|
|
2480
|
-
if (isLeftPromise && isRightPromise) {
|
|
2481
|
-
return promiseAll(
|
|
2482
|
-
[leftResolve, rightResolve]).then(spread2(sameValueZero))
|
|
2483
|
-
} else if (isLeftPromise) {
|
|
2484
|
-
return leftResolve.then(curry2(sameValueZero, __, rightResolve))
|
|
2485
|
-
} else if (isRightPromise) {
|
|
2486
|
-
return rightResolve.then(curry2(sameValueZero, leftResolve, __))
|
|
2487
|
-
}
|
|
2488
|
-
return sameValueZero(leftResolve, rightResolve)
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2340
|
+
// _not(args Array, predicate function)
|
|
2341
|
+
const _not = function (args, predicate) {
|
|
2342
|
+
const boolean = predicate(...args)
|
|
2343
|
+
return isPromise(boolean) ? boolean.then(negate) : !boolean
|
|
2344
|
+
}
|
|
2491
2345
|
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
: sameValueZero(leftResolve, right)
|
|
2346
|
+
const not = function (...args) {
|
|
2347
|
+
const predicateOrValue = args.pop()
|
|
2348
|
+
if (typeof predicateOrValue == 'function') {
|
|
2349
|
+
if (args.length == 0) {
|
|
2350
|
+
return curryArgs2(_not, __, predicateOrValue)
|
|
2498
2351
|
}
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
return function equalBy(value) {
|
|
2502
|
-
const rightResolve = right(value)
|
|
2503
|
-
return isPromise(rightResolve)
|
|
2504
|
-
? rightResolve.then(curry2(sameValueZero, left, __))
|
|
2505
|
-
: sameValueZero(left, rightResolve)
|
|
2352
|
+
if (areAnyValuesPromises(args)) {
|
|
2353
|
+
return promiseAll(args).then(curry2(_not, __, predicateOrValue))
|
|
2506
2354
|
}
|
|
2355
|
+
return _not(args, predicateOrValue)
|
|
2507
2356
|
}
|
|
2357
|
+
return !predicateOrValue
|
|
2358
|
+
}
|
|
2508
2359
|
|
|
2509
|
-
|
|
2360
|
+
// argument resolver for curryArgs4
|
|
2361
|
+
const curryArgs4ResolveArgs0 = (
|
|
2362
|
+
baseFunc, arg1, arg2, arg3,
|
|
2363
|
+
) => function args0Resolver(...args) {
|
|
2364
|
+
return baseFunc(args, arg1, arg2, arg3)
|
|
2510
2365
|
}
|
|
2511
2366
|
|
|
2512
|
-
|
|
2367
|
+
// argument resolver for curryArgs4
|
|
2368
|
+
const curryArgs4ResolveArgs1 = (
|
|
2369
|
+
baseFunc, arg0, arg2, arg3,
|
|
2370
|
+
) => function args1Resolver(...args) {
|
|
2371
|
+
return baseFunc(arg0, args, arg2, arg3)
|
|
2372
|
+
}
|
|
2513
2373
|
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2374
|
+
// argument resolver for curryArgs4
|
|
2375
|
+
const curryArgs4ResolveArgs2 = (
|
|
2376
|
+
baseFunc, arg0, arg1, arg3,
|
|
2377
|
+
) => function args2Resolver(...args) {
|
|
2378
|
+
return baseFunc(arg0, arg1, args, arg3)
|
|
2379
|
+
}
|
|
2517
2380
|
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
if (isLeftPromise && isRightPromise) {
|
|
2525
|
-
return promiseAll(
|
|
2526
|
-
[leftResolve, rightResolve]).then(spread2(greaterThan))
|
|
2527
|
-
} else if (isLeftPromise) {
|
|
2528
|
-
return leftResolve.then(curry2(greaterThan, __, rightResolve))
|
|
2529
|
-
} else if (isRightPromise) {
|
|
2530
|
-
return rightResolve.then(curry2(greaterThan, leftResolve, __))
|
|
2531
|
-
}
|
|
2532
|
-
return leftResolve > rightResolve
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2381
|
+
// argument resolver for curryArgs4
|
|
2382
|
+
const curryArgs4ResolveArgs3 = (
|
|
2383
|
+
baseFunc, arg0, arg1, arg2,
|
|
2384
|
+
) => function args3Resolver(...args) {
|
|
2385
|
+
return baseFunc(arg0, arg1, arg2, args)
|
|
2386
|
+
}
|
|
2535
2387
|
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
return isPromise(leftResolve)
|
|
2540
|
-
? leftResolve.then(curry2(greaterThan, __, right))
|
|
2541
|
-
: leftResolve > right
|
|
2542
|
-
}
|
|
2388
|
+
const curryArgs4 = function (baseFunc, arg0, arg1, arg2, arg3) {
|
|
2389
|
+
if (arg0 == __) {
|
|
2390
|
+
return curryArgs4ResolveArgs0(baseFunc, arg1, arg2, arg3)
|
|
2543
2391
|
}
|
|
2544
|
-
if (
|
|
2545
|
-
return
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2392
|
+
if (arg1 == __) {
|
|
2393
|
+
return curryArgs4ResolveArgs1(baseFunc, arg0, arg2, arg3)
|
|
2394
|
+
}
|
|
2395
|
+
if (arg2 == __) {
|
|
2396
|
+
return curryArgs4ResolveArgs2(baseFunc, arg0, arg1, arg3)
|
|
2397
|
+
}
|
|
2398
|
+
return curryArgs4ResolveArgs3(baseFunc, arg0, arg1, arg2)
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
// leftResolverRightResolverCompare(
|
|
2402
|
+
// args Array, comparator function, left function, right function,
|
|
2403
|
+
// ) -> Promise|boolean
|
|
2404
|
+
const leftResolverRightResolverCompare = function (
|
|
2405
|
+
args, comparator, left, right,
|
|
2406
|
+
) {
|
|
2407
|
+
const leftResult = left(...args),
|
|
2408
|
+
rightResult = right(...args)
|
|
2409
|
+
if (isPromise(leftResult) || isPromise(rightResult)) {
|
|
2410
|
+
return promiseAll([leftResult, rightResult]).then(spread2(comparator))
|
|
2551
2411
|
}
|
|
2412
|
+
return comparator(leftResult, rightResult)
|
|
2413
|
+
}
|
|
2552
2414
|
|
|
2553
|
-
|
|
2415
|
+
// leftResolverRightValueCompare(
|
|
2416
|
+
// args Array, comparator function, left function, right any
|
|
2417
|
+
// ) -> Promise|boolean
|
|
2418
|
+
const leftResolverRightValueCompare = function (args, comparator, left, right) {
|
|
2419
|
+
const leftResult = left(...args)
|
|
2420
|
+
if (isPromise(leftResult) || isPromise(right)) {
|
|
2421
|
+
return promiseAll([leftResult, right]).then(spread2(comparator))
|
|
2422
|
+
}
|
|
2423
|
+
return comparator(leftResult, right)
|
|
2554
2424
|
}
|
|
2555
2425
|
|
|
2556
|
-
|
|
2426
|
+
// leftValueRightResolverCompare(
|
|
2427
|
+
// args Array, comparator function, left any, right any,
|
|
2428
|
+
// ) -> Promise|boolean
|
|
2429
|
+
const leftValueRightResolverCompare = function (args, comparator, left, right) {
|
|
2430
|
+
const rightResult = right(...args)
|
|
2431
|
+
if (isPromise(left) || isPromise(rightResult)) {
|
|
2432
|
+
return promiseAll([left, rightResult]).then(spread2(comparator))
|
|
2433
|
+
}
|
|
2434
|
+
return comparator(left, rightResult)
|
|
2435
|
+
}
|
|
2557
2436
|
|
|
2558
|
-
|
|
2437
|
+
// ComparisonOperator(comparator function) -> operator function
|
|
2438
|
+
const ComparisonOperator = comparator => function operator(...args) {
|
|
2439
|
+
const right = args.pop()
|
|
2440
|
+
const left = args.pop()
|
|
2559
2441
|
const isLeftResolver = typeof left == 'function',
|
|
2560
2442
|
isRightResolver = typeof right == 'function'
|
|
2561
2443
|
|
|
2562
2444
|
if (isLeftResolver && isRightResolver) {
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
return leftResolve.then(curry2(lessThan, __, rightResolve))
|
|
2573
|
-
} else if (isRightPromise) {
|
|
2574
|
-
return rightResolve.then(curry2(lessThan, leftResolve, __))
|
|
2575
|
-
}
|
|
2576
|
-
return leftResolve < rightResolve
|
|
2445
|
+
if (args.length == 0) {
|
|
2446
|
+
return curryArgs4(
|
|
2447
|
+
leftResolverRightResolverCompare, __, comparator, left, right,
|
|
2448
|
+
)
|
|
2449
|
+
}
|
|
2450
|
+
if (areAnyValuesPromises(args)) {
|
|
2451
|
+
return promiseAll(args).then(curry4(
|
|
2452
|
+
leftResolverRightResolverCompare, __, comparator, left, right,
|
|
2453
|
+
))
|
|
2577
2454
|
}
|
|
2455
|
+
return leftResolverRightResolverCompare(args, comparator, left, right)
|
|
2578
2456
|
}
|
|
2579
2457
|
|
|
2580
2458
|
if (isLeftResolver) {
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
: leftResolve < right
|
|
2459
|
+
if (args.length == 0) {
|
|
2460
|
+
return curryArgs4(
|
|
2461
|
+
leftResolverRightValueCompare, __, comparator, left, right,
|
|
2462
|
+
)
|
|
2586
2463
|
}
|
|
2464
|
+
if (areAnyValuesPromises(args)) {
|
|
2465
|
+
return promiseAll(args).then(curry4(
|
|
2466
|
+
leftResolverRightValueCompare, __, comparator, left, right,
|
|
2467
|
+
))
|
|
2468
|
+
}
|
|
2469
|
+
return leftResolverRightValueCompare(args, comparator, left, right)
|
|
2587
2470
|
}
|
|
2471
|
+
|
|
2588
2472
|
if (isRightResolver) {
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
: left < rightResolve
|
|
2473
|
+
if (args.length == 0) {
|
|
2474
|
+
return curryArgs4(
|
|
2475
|
+
leftValueRightResolverCompare, __, comparator, left, right,
|
|
2476
|
+
)
|
|
2594
2477
|
}
|
|
2478
|
+
if (areAnyValuesPromises(args)) {
|
|
2479
|
+
return promiseAll(args).then(curry4(
|
|
2480
|
+
leftValueRightResolverCompare, __, comparator, left, right,
|
|
2481
|
+
))
|
|
2482
|
+
}
|
|
2483
|
+
return leftValueRightResolverCompare(args, comparator, left, right)
|
|
2595
2484
|
}
|
|
2596
2485
|
|
|
2597
|
-
|
|
2486
|
+
if (isPromise(left) || isPromise(right)) {
|
|
2487
|
+
return promiseAll([left, right]).then(spread2(comparator))
|
|
2488
|
+
}
|
|
2489
|
+
return comparator(left, right)
|
|
2598
2490
|
}
|
|
2599
2491
|
|
|
2600
|
-
const
|
|
2492
|
+
const equals = function (left, right) {
|
|
2493
|
+
return left == right
|
|
2494
|
+
}
|
|
2601
2495
|
|
|
2602
|
-
const
|
|
2603
|
-
const isLeftResolver = typeof left == 'function',
|
|
2604
|
-
isRightResolver = typeof right == 'function'
|
|
2496
|
+
const eq = ComparisonOperator(equals)
|
|
2605
2497
|
|
|
2606
|
-
|
|
2607
|
-
return function greaterThanOrEqualBy(value) {
|
|
2608
|
-
const leftResolve = left(value),
|
|
2609
|
-
rightResolve = right(value)
|
|
2610
|
-
const isLeftPromise = isPromise(leftResolve),
|
|
2611
|
-
isRightPromise = isPromise(rightResolve)
|
|
2612
|
-
if (isLeftPromise && isRightPromise) {
|
|
2613
|
-
return promiseAll(
|
|
2614
|
-
[leftResolve, rightResolve]).then(spread2(greaterThanOrEqual))
|
|
2615
|
-
} else if (isLeftPromise) {
|
|
2616
|
-
return leftResolve.then(curry2(greaterThanOrEqual, __, rightResolve))
|
|
2617
|
-
} else if (isRightPromise) {
|
|
2618
|
-
return rightResolve.then(curry2(greaterThanOrEqual, leftResolve, __))
|
|
2619
|
-
}
|
|
2620
|
-
return leftResolve >= rightResolve
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2498
|
+
const greaterThan = (left, right) => left > right
|
|
2623
2499
|
|
|
2624
|
-
|
|
2625
|
-
return function greaterThanOrEqualBy(value) {
|
|
2626
|
-
const leftResolve = left(value)
|
|
2627
|
-
return isPromise(leftResolve)
|
|
2628
|
-
? leftResolve.then(curry2(greaterThanOrEqual, __, right))
|
|
2629
|
-
: leftResolve >= right
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
if (isRightResolver) {
|
|
2633
|
-
return function greaterThanOrEqualBy(value) {
|
|
2634
|
-
const rightResolve = right(value)
|
|
2635
|
-
return isPromise(rightResolve)
|
|
2636
|
-
? rightResolve.then(curry2(greaterThanOrEqual, left, __))
|
|
2637
|
-
: left >= rightResolve
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2500
|
+
const gt = ComparisonOperator(greaterThan)
|
|
2640
2501
|
|
|
2641
|
-
|
|
2642
|
-
}
|
|
2502
|
+
const lessThan = (left, right) => left < right
|
|
2643
2503
|
|
|
2644
|
-
const
|
|
2504
|
+
const lt = ComparisonOperator(lessThan)
|
|
2645
2505
|
|
|
2646
|
-
const
|
|
2647
|
-
const isLeftResolver = typeof left == 'function',
|
|
2648
|
-
isRightResolver = typeof right == 'function'
|
|
2506
|
+
const greaterThanOrEqual = (left, right) => left >= right
|
|
2649
2507
|
|
|
2650
|
-
|
|
2651
|
-
return function lessThanOrEqualBy(value) {
|
|
2652
|
-
const leftResolve = left(value),
|
|
2653
|
-
rightResolve = right(value)
|
|
2654
|
-
const isLeftPromise = isPromise(leftResolve),
|
|
2655
|
-
isRightPromise = isPromise(rightResolve)
|
|
2656
|
-
if (isLeftPromise && isRightPromise) {
|
|
2657
|
-
return promiseAll(
|
|
2658
|
-
[leftResolve, rightResolve]).then(spread2(lessThanOrEqual))
|
|
2659
|
-
} else if (isLeftPromise) {
|
|
2660
|
-
return leftResolve.then(curry2(lessThanOrEqual, __, rightResolve))
|
|
2661
|
-
} else if (isRightPromise) {
|
|
2662
|
-
return rightResolve.then(curry2(lessThanOrEqual, leftResolve, __))
|
|
2663
|
-
}
|
|
2664
|
-
return leftResolve <= rightResolve
|
|
2665
|
-
}
|
|
2666
|
-
}
|
|
2508
|
+
const gte = ComparisonOperator(greaterThanOrEqual)
|
|
2667
2509
|
|
|
2668
|
-
|
|
2669
|
-
return function lessThanOrEqualBy(value) {
|
|
2670
|
-
const leftResolve = left(value)
|
|
2671
|
-
return isPromise(leftResolve)
|
|
2672
|
-
? leftResolve.then(curry2(lessThanOrEqual, __, right))
|
|
2673
|
-
: leftResolve <= right
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
|
-
if (isRightResolver) {
|
|
2677
|
-
return function lessThanOrEqualBy(value) {
|
|
2678
|
-
const rightResolve = right(value)
|
|
2679
|
-
return isPromise(rightResolve)
|
|
2680
|
-
? rightResolve.then(curry2(lessThanOrEqual, left, __))
|
|
2681
|
-
: left <= rightResolve
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2510
|
+
const lessThanOrEqual = (left, right) => left <= right
|
|
2684
2511
|
|
|
2685
|
-
|
|
2686
|
-
}
|
|
2512
|
+
const lte = ComparisonOperator(lessThanOrEqual)
|
|
2687
2513
|
|
|
2688
2514
|
const memoizeCappedUnary = function (func, cap) {
|
|
2689
2515
|
const cache = new Map(),
|
|
@@ -2743,13 +2569,24 @@ const getByPath = function (value, path) {
|
|
|
2743
2569
|
return result
|
|
2744
2570
|
}
|
|
2745
2571
|
|
|
2746
|
-
|
|
2747
|
-
|
|
2572
|
+
// _get(object Object, path string, defaultValue function|any)
|
|
2573
|
+
const _get = function (object, path, defaultValue) {
|
|
2574
|
+
const result = object == null ? undefined : getByPath(object, path)
|
|
2748
2575
|
return result === undefined
|
|
2749
|
-
? typeof defaultValue == 'function' ? defaultValue(
|
|
2576
|
+
? typeof defaultValue == 'function' ? defaultValue(object) : defaultValue
|
|
2750
2577
|
: result
|
|
2751
2578
|
}
|
|
2752
2579
|
|
|
2580
|
+
const get = function (arg0, arg1, arg2) {
|
|
2581
|
+
if (isPromise(arg0)) {
|
|
2582
|
+
return arg0.then(curry3(_get, __, arg1, arg2))
|
|
2583
|
+
}
|
|
2584
|
+
if (isObject(arg0) && !isArray(arg0)) {
|
|
2585
|
+
return _get(arg0, arg1, arg2)
|
|
2586
|
+
}
|
|
2587
|
+
return curry3(_get, __, arg0, arg1)
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2753
2590
|
const setByPath = function (obj, value, path) {
|
|
2754
2591
|
if (!isObject(obj)){
|
|
2755
2592
|
return obj
|
|
@@ -2775,7 +2612,7 @@ const setByPath = function (obj, value, path) {
|
|
|
2775
2612
|
return result
|
|
2776
2613
|
}
|
|
2777
2614
|
|
|
2778
|
-
const
|
|
2615
|
+
const _set = function (obj, path, value) {
|
|
2779
2616
|
if (typeof value == 'function') {
|
|
2780
2617
|
const actualValue = value(obj)
|
|
2781
2618
|
if (isPromise(actualValue)) {
|
|
@@ -2785,9 +2622,24 @@ const set = (path, value) => function setter(obj) {
|
|
|
2785
2622
|
}
|
|
2786
2623
|
return setByPath(obj, actualValue, path)
|
|
2787
2624
|
}
|
|
2625
|
+
if (isPromise(value)) {
|
|
2626
|
+
return value.then(
|
|
2627
|
+
curry3(setByPath, obj, __, path)
|
|
2628
|
+
)
|
|
2629
|
+
}
|
|
2788
2630
|
return setByPath(obj, value, path)
|
|
2789
2631
|
}
|
|
2790
2632
|
|
|
2633
|
+
const set = function (arg0, arg1, arg2) {
|
|
2634
|
+
if (arg2 == null) {
|
|
2635
|
+
return curry3(_set, __, arg0, arg1)
|
|
2636
|
+
}
|
|
2637
|
+
if (isPromise(arg0)) {
|
|
2638
|
+
return arg0.then(curry3(_set, __, arg1, arg2))
|
|
2639
|
+
}
|
|
2640
|
+
return _set(arg0, arg1, arg2)
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2791
2643
|
// _pick(source Object, keys Array<string>) -> result Object
|
|
2792
2644
|
const _pick = function (source, keys) {
|
|
2793
2645
|
if (source == null) {
|
|
@@ -2806,10 +2658,13 @@ const _pick = function (source, keys) {
|
|
|
2806
2658
|
return result
|
|
2807
2659
|
}
|
|
2808
2660
|
|
|
2809
|
-
const pick = (arg0, arg1)
|
|
2661
|
+
const pick = function (arg0, arg1) {
|
|
2810
2662
|
if (arg1 == null) {
|
|
2811
2663
|
return curry2(_pick, __, arg0)
|
|
2812
2664
|
}
|
|
2665
|
+
if (isPromise(arg0)) {
|
|
2666
|
+
return arg0.then(curry2(_pick, __, arg1))
|
|
2667
|
+
}
|
|
2813
2668
|
return _pick(arg0, arg1)
|
|
2814
2669
|
}
|
|
2815
2670
|
|
|
@@ -2896,10 +2751,16 @@ const omit = function (arg0, arg1) {
|
|
|
2896
2751
|
if (arg1 == null) {
|
|
2897
2752
|
return curry2(_omit, __, arg0)
|
|
2898
2753
|
}
|
|
2754
|
+
if (isPromise(arg0)) {
|
|
2755
|
+
return arg0.then(curry2(_omit, __, arg1))
|
|
2756
|
+
}
|
|
2899
2757
|
return _omit(arg0, arg1)
|
|
2900
2758
|
}
|
|
2901
2759
|
|
|
2902
2760
|
const thunkify = (func, ...args) => function thunk() {
|
|
2761
|
+
if (areAnyValuesPromises(args)) {
|
|
2762
|
+
return promiseAll(args).then(curry2(funcApply, func, __))
|
|
2763
|
+
}
|
|
2903
2764
|
return func(...args)
|
|
2904
2765
|
}
|
|
2905
2766
|
|
|
@@ -2910,11 +2771,11 @@ curry.arity = function curryArity_(arity, func, ...args) {
|
|
|
2910
2771
|
}
|
|
2911
2772
|
|
|
2912
2773
|
const rubico = {
|
|
2913
|
-
pipe, tap,
|
|
2774
|
+
pipe, compose, tap,
|
|
2914
2775
|
switchCase, tryCatch,
|
|
2915
|
-
|
|
2916
|
-
map, filter, reduce, transform,
|
|
2917
|
-
and, or, not,
|
|
2776
|
+
all, assign, get, set, pick, omit,
|
|
2777
|
+
map, filter, flatMap, forEach, reduce, transform,
|
|
2778
|
+
and, or, not, some, every,
|
|
2918
2779
|
eq, gt, lt, gte, lte,
|
|
2919
2780
|
thunkify, always,
|
|
2920
2781
|
curry, __,
|