rubico 2.0.1 → 2.2.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/README.md +10 -8
- package/Transducer.js +28 -0
- package/_internal/genericTransform.js +30 -28
- package/_internal/reducerTryCatch.js +55 -0
- package/dist/Transducer.es.js +28 -1
- package/dist/Transducer.es.min.js +2 -2
- package/dist/Transducer.js +28 -1
- package/dist/Transducer.min.js +2 -2
- package/dist/Transducer.mjs +28 -1
- package/dist/__.es.js +1 -1
- package/dist/__.es.min.js +1 -1
- package/dist/__.js +1 -1
- package/dist/__.min.js +1 -1
- package/dist/__.mjs +1 -1
- package/dist/all.es.js +1 -1
- package/dist/all.es.min.js +1 -1
- package/dist/all.js +1 -1
- package/dist/all.min.js +1 -1
- package/dist/all.mjs +1 -1
- package/dist/always.es.js +1 -1
- package/dist/always.es.min.js +1 -1
- package/dist/always.js +1 -1
- package/dist/always.min.js +1 -1
- package/dist/always.mjs +1 -1
- package/dist/and.es.js +1 -1
- package/dist/and.es.min.js +1 -1
- package/dist/and.js +1 -1
- package/dist/and.min.js +1 -1
- package/dist/and.mjs +1 -1
- package/dist/assign.es.js +1 -1
- package/dist/assign.es.min.js +1 -1
- package/dist/assign.js +1 -1
- package/dist/assign.min.js +1 -1
- package/dist/assign.mjs +1 -1
- package/dist/compose.es.js +1 -1
- package/dist/compose.es.min.js +1 -1
- package/dist/compose.js +1 -1
- package/dist/compose.min.js +1 -1
- package/dist/compose.mjs +1 -1
- package/dist/curry.es.js +1 -1
- package/dist/curry.es.min.js +1 -1
- package/dist/curry.js +1 -1
- package/dist/curry.min.js +1 -1
- package/dist/curry.mjs +1 -1
- package/dist/eq.es.js +1 -1
- package/dist/eq.es.min.js +1 -1
- package/dist/eq.js +1 -1
- package/dist/eq.min.js +1 -1
- package/dist/eq.mjs +1 -1
- package/dist/every.es.js +1 -1
- package/dist/every.es.min.js +1 -1
- package/dist/every.js +1 -1
- package/dist/every.min.js +1 -1
- package/dist/every.mjs +1 -1
- package/dist/filter.es.js +1 -1
- package/dist/filter.es.min.js +1 -1
- package/dist/filter.js +1 -1
- package/dist/filter.min.js +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/flatMap.es.js +1 -1
- package/dist/flatMap.es.min.js +1 -1
- package/dist/flatMap.js +1 -1
- package/dist/flatMap.min.js +1 -1
- package/dist/flatMap.mjs +1 -1
- package/dist/forEach.es.js +1 -1
- package/dist/forEach.es.min.js +1 -1
- package/dist/forEach.js +1 -1
- package/dist/forEach.min.js +1 -1
- package/dist/forEach.mjs +1 -1
- package/dist/get.es.js +1 -1
- package/dist/get.es.min.js +1 -1
- package/dist/get.js +1 -1
- package/dist/get.min.js +1 -1
- package/dist/get.mjs +1 -1
- package/dist/gt.es.js +1 -1
- package/dist/gt.es.min.js +1 -1
- package/dist/gt.js +1 -1
- package/dist/gt.min.js +1 -1
- package/dist/gt.mjs +1 -1
- package/dist/gte.es.js +1 -1
- package/dist/gte.es.min.js +1 -1
- package/dist/gte.js +1 -1
- package/dist/gte.min.js +1 -1
- package/dist/gte.mjs +1 -1
- package/dist/lt.es.js +1 -1
- package/dist/lt.es.min.js +1 -1
- package/dist/lt.js +1 -1
- package/dist/lt.min.js +1 -1
- package/dist/lt.mjs +1 -1
- package/dist/lte.es.js +1 -1
- package/dist/lte.es.min.js +1 -1
- package/dist/lte.js +1 -1
- package/dist/lte.min.js +1 -1
- package/dist/lte.mjs +1 -1
- package/dist/map.es.js +1 -1
- package/dist/map.es.min.js +1 -1
- package/dist/map.js +1 -1
- package/dist/map.min.js +1 -1
- package/dist/map.mjs +1 -1
- package/dist/not.es.js +1 -1
- package/dist/not.es.min.js +1 -1
- package/dist/not.js +1 -1
- package/dist/not.min.js +1 -1
- package/dist/not.mjs +1 -1
- package/dist/omit.es.js +1 -1
- package/dist/omit.es.min.js +1 -1
- package/dist/omit.js +1 -1
- package/dist/omit.min.js +1 -1
- package/dist/omit.mjs +1 -1
- package/dist/or.es.js +1 -1
- package/dist/or.es.min.js +1 -1
- package/dist/or.js +1 -1
- package/dist/or.min.js +1 -1
- package/dist/or.mjs +1 -1
- package/dist/pick.es.js +1 -1
- package/dist/pick.es.min.js +1 -1
- package/dist/pick.js +1 -1
- package/dist/pick.min.js +1 -1
- package/dist/pick.mjs +1 -1
- package/dist/pipe.es.js +1 -1
- package/dist/pipe.es.min.js +1 -1
- package/dist/pipe.js +1 -1
- package/dist/pipe.min.js +1 -1
- package/dist/pipe.mjs +1 -1
- package/dist/reduce.es.js +1 -1
- package/dist/reduce.es.min.js +1 -1
- package/dist/reduce.js +1 -1
- package/dist/reduce.min.js +1 -1
- package/dist/reduce.mjs +1 -1
- package/dist/rubico.es.js +57 -46
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +57 -46
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +57 -46
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +57 -46
- package/dist/set.es.js +1 -1
- package/dist/set.es.min.js +1 -1
- package/dist/set.js +1 -1
- package/dist/set.min.js +1 -1
- package/dist/set.mjs +1 -1
- package/dist/some.es.js +1 -1
- package/dist/some.es.min.js +1 -1
- package/dist/some.js +1 -1
- package/dist/some.min.js +1 -1
- package/dist/some.mjs +1 -1
- package/dist/switchCase.es.js +1 -1
- package/dist/switchCase.es.min.js +1 -1
- package/dist/switchCase.js +1 -1
- package/dist/switchCase.min.js +1 -1
- package/dist/switchCase.mjs +1 -1
- package/dist/tap.es.js +32 -2
- package/dist/tap.es.min.js +2 -2
- package/dist/tap.js +32 -2
- package/dist/tap.min.js +2 -2
- package/dist/tap.mjs +32 -2
- package/dist/thunkify.es.js +1 -1
- package/dist/thunkify.es.min.js +1 -1
- package/dist/thunkify.js +1 -1
- package/dist/thunkify.min.js +1 -1
- package/dist/thunkify.mjs +1 -1
- package/dist/transform.es.js +26 -24
- package/dist/transform.es.min.js +2 -2
- package/dist/transform.js +26 -24
- package/dist/transform.min.js +2 -2
- package/dist/transform.mjs +26 -24
- package/dist/tryCatch.es.js +1 -1
- package/dist/tryCatch.es.min.js +1 -1
- package/dist/tryCatch.js +1 -1
- package/dist/tryCatch.min.js +1 -1
- package/dist/tryCatch.mjs +1 -1
- package/dist/x/append.es.js +1 -1
- package/dist/x/append.es.min.js +1 -1
- package/dist/x/append.js +1 -1
- package/dist/x/append.min.js +1 -1
- package/dist/x/append.mjs +1 -1
- package/dist/x/callProp.es.js +1 -1
- package/dist/x/callProp.es.min.js +1 -1
- package/dist/x/callProp.js +1 -1
- package/dist/x/callProp.min.js +1 -1
- package/dist/x/callProp.mjs +1 -1
- package/dist/x/defaultsDeep.es.js +1 -1
- package/dist/x/defaultsDeep.es.min.js +1 -1
- package/dist/x/defaultsDeep.js +1 -1
- package/dist/x/defaultsDeep.min.js +1 -1
- package/dist/x/defaultsDeep.mjs +1 -1
- package/dist/x/differenceWith.es.js +1 -1
- package/dist/x/differenceWith.es.min.js +1 -1
- package/dist/x/differenceWith.js +1 -1
- package/dist/x/differenceWith.min.js +1 -1
- package/dist/x/differenceWith.mjs +1 -1
- package/dist/x/filterOut.es.js +1 -1
- package/dist/x/filterOut.es.min.js +1 -1
- package/dist/x/filterOut.js +1 -1
- package/dist/x/filterOut.min.js +1 -1
- package/dist/x/filterOut.mjs +1 -1
- package/dist/x/find.es.js +1 -1
- package/dist/x/find.es.min.js +1 -1
- package/dist/x/find.js +1 -1
- package/dist/x/find.min.js +1 -1
- package/dist/x/find.mjs +1 -1
- package/dist/x/findIndex.es.js +1 -1
- package/dist/x/findIndex.es.min.js +1 -1
- package/dist/x/findIndex.js +1 -1
- package/dist/x/findIndex.min.js +1 -1
- package/dist/x/findIndex.mjs +1 -1
- package/dist/x/first.es.js +1 -1
- package/dist/x/first.es.min.js +1 -1
- package/dist/x/first.js +1 -1
- package/dist/x/first.min.js +1 -1
- package/dist/x/first.mjs +1 -1
- package/dist/x/flatten.es.js +1 -1
- package/dist/x/flatten.es.min.js +1 -1
- package/dist/x/flatten.js +1 -1
- package/dist/x/flatten.min.js +1 -1
- package/dist/x/flatten.mjs +1 -1
- package/dist/x/groupBy.es.js +1 -1
- package/dist/x/groupBy.es.min.js +1 -1
- package/dist/x/groupBy.js +1 -1
- package/dist/x/groupBy.min.js +1 -1
- package/dist/x/groupBy.mjs +1 -1
- package/dist/x/has.es.js +1 -1
- package/dist/x/has.es.min.js +1 -1
- package/dist/x/has.js +1 -1
- package/dist/x/has.min.js +1 -1
- package/dist/x/has.mjs +1 -1
- package/dist/x/identity.es.js +1 -1
- package/dist/x/identity.es.min.js +1 -1
- package/dist/x/identity.js +1 -1
- package/dist/x/identity.min.js +1 -1
- package/dist/x/identity.mjs +1 -1
- package/dist/x/includes.es.js +1 -1
- package/dist/x/includes.es.min.js +1 -1
- package/dist/x/includes.js +1 -1
- package/dist/x/includes.min.js +1 -1
- package/dist/x/includes.mjs +1 -1
- package/dist/x/isDeepEqual.es.js +1 -1
- package/dist/x/isDeepEqual.es.min.js +1 -1
- package/dist/x/isDeepEqual.js +1 -1
- package/dist/x/isDeepEqual.min.js +1 -1
- package/dist/x/isDeepEqual.mjs +1 -1
- package/dist/x/isEmpty.es.js +1 -1
- package/dist/x/isEmpty.es.min.js +1 -1
- package/dist/x/isEmpty.js +1 -1
- package/dist/x/isEmpty.min.js +1 -1
- package/dist/x/isEmpty.mjs +1 -1
- package/dist/x/isEqual.es.js +1 -1
- package/dist/x/isEqual.es.min.js +1 -1
- package/dist/x/isEqual.js +1 -1
- package/dist/x/isEqual.min.js +1 -1
- package/dist/x/isEqual.mjs +1 -1
- package/dist/x/isFunction.es.js +1 -1
- package/dist/x/isFunction.es.min.js +1 -1
- package/dist/x/isFunction.js +1 -1
- package/dist/x/isFunction.min.js +1 -1
- package/dist/x/isFunction.mjs +1 -1
- package/dist/x/isIn.es.js +1 -1
- package/dist/x/isIn.es.min.js +1 -1
- package/dist/x/isIn.js +1 -1
- package/dist/x/isIn.min.js +1 -1
- package/dist/x/isIn.mjs +1 -1
- package/dist/x/isObject.es.js +1 -1
- package/dist/x/isObject.es.min.js +1 -1
- package/dist/x/isObject.js +1 -1
- package/dist/x/isObject.min.js +1 -1
- package/dist/x/isObject.mjs +1 -1
- package/dist/x/isString.es.js +1 -1
- package/dist/x/isString.es.min.js +1 -1
- package/dist/x/isString.js +1 -1
- package/dist/x/isString.min.js +1 -1
- package/dist/x/isString.mjs +1 -1
- package/dist/x/keys.es.js +1 -1
- package/dist/x/keys.es.min.js +1 -1
- package/dist/x/keys.js +1 -1
- package/dist/x/keys.min.js +1 -1
- package/dist/x/keys.mjs +1 -1
- package/dist/x/last.es.js +1 -1
- package/dist/x/last.es.min.js +1 -1
- package/dist/x/last.js +1 -1
- package/dist/x/last.min.js +1 -1
- package/dist/x/last.mjs +1 -1
- package/dist/x/maxBy.es.js +1 -1
- package/dist/x/maxBy.es.min.js +1 -1
- package/dist/x/maxBy.js +1 -1
- package/dist/x/maxBy.min.js +1 -1
- package/dist/x/maxBy.mjs +1 -1
- package/dist/x/noop.es.js +1 -1
- package/dist/x/noop.es.min.js +1 -1
- package/dist/x/noop.js +1 -1
- package/dist/x/noop.min.js +1 -1
- package/dist/x/noop.mjs +1 -1
- package/dist/x/pluck.es.js +1 -1
- package/dist/x/pluck.es.min.js +1 -1
- package/dist/x/pluck.js +1 -1
- package/dist/x/pluck.min.js +1 -1
- package/dist/x/pluck.mjs +1 -1
- package/dist/x/prepend.es.js +1 -1
- package/dist/x/prepend.es.min.js +1 -1
- package/dist/x/prepend.js +1 -1
- package/dist/x/prepend.min.js +1 -1
- package/dist/x/prepend.mjs +1 -1
- package/dist/x/size.es.js +1 -1
- package/dist/x/size.es.min.js +1 -1
- package/dist/x/size.js +1 -1
- package/dist/x/size.min.js +1 -1
- package/dist/x/size.mjs +1 -1
- package/dist/x/trace.es.js +32 -2
- package/dist/x/trace.es.min.js +2 -2
- package/dist/x/trace.js +32 -2
- package/dist/x/trace.min.js +2 -2
- package/dist/x/trace.mjs +32 -2
- package/dist/x/unionWith.es.js +1 -1
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +1 -1
- package/dist/x/unionWith.min.js +1 -1
- package/dist/x/unionWith.mjs +1 -1
- package/dist/x/uniq.es.js +1 -1
- package/dist/x/uniq.es.min.js +1 -1
- package/dist/x/uniq.js +1 -1
- package/dist/x/uniq.min.js +1 -1
- package/dist/x/uniq.mjs +1 -1
- package/dist/x/unless.es.js +1 -1
- package/dist/x/unless.es.min.js +1 -1
- package/dist/x/unless.js +1 -1
- package/dist/x/unless.min.js +1 -1
- package/dist/x/unless.mjs +1 -1
- package/dist/x/values.es.js +1 -1
- package/dist/x/values.es.min.js +1 -1
- package/dist/x/values.js +1 -1
- package/dist/x/values.min.js +1 -1
- package/dist/x/values.mjs +1 -1
- package/dist/x/when.es.js +1 -1
- package/dist/x/when.es.min.js +1 -1
- package/dist/x/when.js +1 -1
- package/dist/x/when.min.js +1 -1
- package/dist/x/when.mjs +1 -1
- package/es.js +57 -46
- package/index.js +57 -46
- package/package.json +43 -2
- package/tap.js +15 -4
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -330
- package/.github/workflows/nodejs.yml +0 -27
- package/.vscode/launch.json +0 -25
- package/AggregateReducer.test.js +0 -82
- package/CHANGELOG.md +0 -310
- package/CNAME +0 -1
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -4
- package/Transducer.test.js +0 -117
- package/_config.yml +0 -1
- package/_internal/improvedGenericTransform.js +0 -93
- package/archive/FlatMappingIterator-2020-09-28.js +0 -68
- package/archive/_Promise-2023-05-29.js +0 -93
- package/archive/arrayMap2-2023-05-29.js +0 -73
- package/archive/benchmarks-v1.9.7/all.js +0 -34
- package/archive/benchmarks-v1.9.7/and.js +0 -24
- package/archive/benchmarks-v1.9.7/any.js +0 -32
- package/archive/benchmarks-v1.9.7/assign.js +0 -174
- package/archive/benchmarks-v1.9.7/curry.js +0 -55
- package/archive/benchmarks-v1.9.7/eq.js +0 -25
- package/archive/benchmarks-v1.9.7/filter.js +0 -1322
- package/archive/benchmarks-v1.9.7/flatMap.js +0 -48
- package/archive/benchmarks-v1.9.7/forEach.js +0 -33
- package/archive/benchmarks-v1.9.7/fork.js +0 -123
- package/archive/benchmarks-v1.9.7/get.js +0 -44
- package/archive/benchmarks-v1.9.7/gt.js +0 -25
- package/archive/benchmarks-v1.9.7/gte.js +0 -25
- package/archive/benchmarks-v1.9.7/integration.js +0 -88
- package/archive/benchmarks-v1.9.7/lt.js +0 -25
- package/archive/benchmarks-v1.9.7/lte.js +0 -25
- package/archive/benchmarks-v1.9.7/map.js +0 -892
- package/archive/benchmarks-v1.9.7/misc.js +0 -470
- package/archive/benchmarks-v1.9.7/omit.js +0 -28
- package/archive/benchmarks-v1.9.7/or.js +0 -51
- package/archive/benchmarks-v1.9.7/pick.js +0 -24
- package/archive/benchmarks-v1.9.7/pipe.js +0 -152
- package/archive/benchmarks-v1.9.7/reduce.js +0 -739
- package/archive/benchmarks-v1.9.7/switchCase.js +0 -256
- package/archive/benchmarks-v1.9.7/tap.js +0 -90
- package/archive/benchmarks-v1.9.7/transform.js +0 -218
- package/archive/benchmarks-v1.9.7/tryCatch.js +0 -108
- package/archive/curry.js +0 -13
- package/archive/examples-v1.6.11/browserModule.html +0 -31
- package/archive/examples-v1.6.11/browserScript.html +0 -32
- package/archive/examples-v1.6.11/coolTransformToConsole.js +0 -1
- package/archive/examples-v1.6.11/denoLargeGasMap.js +0 -85
- package/archive/examples-v1.6.11/denoServer.js +0 -9
- package/archive/examples-v1.6.11/denoServerWithMiddleware.js +0 -55
- package/archive/examples-v1.6.11/logTodosRange.js +0 -21
- package/archive/examples-v1.6.11/makeARequest.html +0 -46
- package/archive/examples-v1.6.11/nodeComplexTransformation.js +0 -106
- package/archive/examples-v1.6.11/nodeConditionallyExtractIDs.js +0 -50
- package/archive/examples-v1.6.11/nodeFloatingPoint.js +0 -55
- package/archive/examples-v1.6.11/nodeGetAllJiraBoards.js +0 -45
- package/archive/examples-v1.6.11/nodeGetSocketIOClientsTotalCount.js +0 -34
- package/archive/examples-v1.6.11/nodeKafkaConsumer.js +0 -63
- package/archive/examples-v1.6.11/nodeMakeMultipleRequests.js +0 -55
- package/archive/examples-v1.6.11/nodeOnRecordAddTask.js +0 -34
- package/archive/examples-v1.6.11/nodePostRequestWithAuth.js +0 -36
- package/archive/examples-v1.6.11/nodeSpeedbackMatchmakingAlgorithm.js +0 -96
- package/archive/examples-v1.6.11/nodeTireData.js +0 -36
- package/archive/examples-v1.6.11/nodeTripleMap.js +0 -85
- package/archive/examples-v1.6.11/squaredOdds.ts +0 -16
- package/archive/examples-v1.6.11/transducerMaxBuyer.js +0 -67
- package/archive/examples-v1.6.11/transformLogTodosRange.js +0 -31
- package/archive/examples-v1.6.11/transformStreamRandomInts.js +0 -19
- package/archive/genericReduceConcurrent.js +0 -277
- package/archive/index.v0.2.9.js +0 -1685
- package/archive/objectValuesGenerator.js +0 -13
- package/archive/test.v0.2.9.js +0 -2334
- package/bench +0 -65
- package/benchmark-output/v1.9.7 +0 -268
- package/benchmarks/all.async.js +0 -43
- package/benchmarks/all.js +0 -43
- package/benchmarks/always.js +0 -15
- package/benchmarks/and.async.js +0 -25
- package/benchmarks/and.js +0 -25
- package/benchmarks/assign.async.js +0 -27
- package/benchmarks/assign.js +0 -27
- package/benchmarks/curry.js +0 -35
- package/benchmarks/eq.async.js +0 -23
- package/benchmarks/eq.js +0 -23
- package/benchmarks/every.async.js +0 -19
- package/benchmarks/every.js +0 -19
- package/benchmarks/filter.async.js +0 -32
- package/benchmarks/filter.js +0 -38
- package/benchmarks/flatMap.async.js +0 -26
- package/benchmarks/flatMap.js +0 -38
- package/benchmarks/get.async.js +0 -19
- package/benchmarks/get.js +0 -39
- package/benchmarks/gt.async.js +0 -23
- package/benchmarks/gt.js +0 -23
- package/benchmarks/gte.async.js +0 -23
- package/benchmarks/gte.js +0 -23
- package/benchmarks/lt.async.js +0 -23
- package/benchmarks/lt.js +0 -23
- package/benchmarks/lte.async.js +0 -23
- package/benchmarks/lte.js +0 -23
- package/benchmarks/map.async.js +0 -43
- package/benchmarks/map.js +0 -40
- package/benchmarks/misc/Promise.js +0 -26
- package/benchmarks/misc/isPromise.js +0 -30
- package/benchmarks/misc/promiseAll.js +0 -36
- package/benchmarks/not.js +0 -23
- package/benchmarks/omit.js +0 -38
- package/benchmarks/or.async.js +0 -25
- package/benchmarks/or.js +0 -25
- package/benchmarks/pick.js +0 -38
- package/benchmarks/pipe.async.js +0 -47
- package/benchmarks/pipe.js +0 -47
- package/benchmarks/reduce.async.js +0 -32
- package/benchmarks/reduce.js +0 -38
- package/benchmarks/set.async.js +0 -19
- package/benchmarks/set.js +0 -41
- package/benchmarks/some.async.js +0 -19
- package/benchmarks/some.js +0 -19
- package/benchmarks/switchCase.async.js +0 -27
- package/benchmarks/switchCase.js +0 -55
- package/benchmarks/tap.js +0 -15
- package/benchmarks/thunkify.js +0 -15
- package/benchmarks/transform.async.js +0 -27
- package/benchmarks/transform.js +0 -40
- package/benchmarks/tryCatch.async.js +0 -25
- package/benchmarks/tryCatch.js +0 -32
- package/build +0 -472
- package/dist-test.js +0 -37
- package/examples/type-to-search-wiki/README.md +0 -19
- package/examples/type-to-search-wiki/package.json +0 -13
- package/examples/type-to-search-wiki/src/app.js +0 -46
- package/examples/type-to-search-wiki/src/index.html +0 -18
- package/import-test.html +0 -73
- package/memory-usage/reduce.js +0 -40
- package/monad/AsyncPool.js +0 -0
- package/monad/BrokenPromise.js +0 -63
- package/monad/BrokenPromise.test.js +0 -22
- package/monad/Cancellable.js +0 -84
- package/monad/Cancellable.memoryUsage.js +0 -60
- package/monad/Cancellable.test.js +0 -20
- package/monad/Function.js +0 -0
- package/monad/Instance.benchmark.js +0 -378
- package/monad/Instance.js +0 -351
- package/monad/Instance.test.js +0 -445
- package/monad/Mux.benchmark.js +0 -29
- package/monad/Mux.js +0 -589
- package/monad/Mux.test.js +0 -512
- package/monad/PossiblePromise.benchmark.js +0 -87
- package/monad/PossiblePromise.js +0 -144
- package/monad/PossiblePromise.test.js +0 -89
- package/monad/README.md +0 -75
- package/monad/Reducer.js +0 -0
- package/monad/Sequence.benchmark.js +0 -42
- package/monad/Sequence.js +0 -36
- package/monad/SpecScript.js +0 -0
- package/monad/Stack.js +0 -0
- package/monad/Struct.benchmark.js +0 -154
- package/monad/Struct.js +0 -249
- package/monad/Struct.test.js +0 -237
- package/rubico.js +0 -66
- package/test.js +0 -4242
- package/tmp.js +0 -1
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { pipe, fork, map, get } = require('rubico')
|
|
4
|
-
|
|
5
|
-
const requestAPI = record => {/* make API request */}
|
|
6
|
-
|
|
7
|
-
const saveToDatabase = result => {/* save result to database */}
|
|
8
|
-
|
|
9
|
-
const getImages = apiResult => {/* make images API request */}
|
|
10
|
-
|
|
11
|
-
const flatten = arr => arr.flat(1)
|
|
12
|
-
|
|
13
|
-
const uploadToS3 = image => {/* upload to s3 code */}
|
|
14
|
-
|
|
15
|
-
/*
|
|
16
|
-
const onRecordAddTask = async record => {
|
|
17
|
-
const results = await requestAPI(record)
|
|
18
|
-
const [arraysOfImages,] = await Promise.all([
|
|
19
|
-
await Promise.all(results.map(getImages)),
|
|
20
|
-
await Promise.all(results.map(saveToDatabase)),
|
|
21
|
-
])
|
|
22
|
-
await Promise.all(flatten(arraysOfImages).map(uploadToS3))
|
|
23
|
-
}
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const onRecordAddTask = pipe([
|
|
27
|
-
requestAPI,
|
|
28
|
-
fork([
|
|
29
|
-
map(getImages),
|
|
30
|
-
map(saveToDatabase),
|
|
31
|
-
]),
|
|
32
|
-
get(0),
|
|
33
|
-
map(map(uploadToS3)),
|
|
34
|
-
])
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fetch = require('node-fetch')
|
|
4
|
-
const { pipe, fork, get } = require('..')
|
|
5
|
-
|
|
6
|
-
const getToken = () => 'token'
|
|
7
|
-
|
|
8
|
-
const getJSON = res => res.json()
|
|
9
|
-
|
|
10
|
-
// expects the object { body: {...}, uuid: 'string' }
|
|
11
|
-
const postRequestWithAuth = route => pipe([
|
|
12
|
-
fork({
|
|
13
|
-
method: () => 'POST',
|
|
14
|
-
headers: pipe([
|
|
15
|
-
get('uuid'),
|
|
16
|
-
getToken,
|
|
17
|
-
token => ({
|
|
18
|
-
Authorization: `Token ${token}`,
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
|
-
}),
|
|
21
|
-
]),
|
|
22
|
-
body: pipe([
|
|
23
|
-
get('body'),
|
|
24
|
-
JSON.stringify,
|
|
25
|
-
]),
|
|
26
|
-
}),
|
|
27
|
-
payload => fetch(route, payload),
|
|
28
|
-
getJSON,
|
|
29
|
-
])
|
|
30
|
-
|
|
31
|
-
postRequestWithAuth('http://localhost:8001/myRoute')({
|
|
32
|
-
uuid: 'ffda7b1c-fc6b-4949-98c4-e5cb86675f5f',
|
|
33
|
-
body: { hello: 'world' },
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// https://stackoverflow.com/questions/54852314/javascript-functional-programming-how-to-handle-fetch-for-pipes/61907662#61907662
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
pipe, fork, tap, switchCase,
|
|
5
|
-
map, filter, transform,
|
|
6
|
-
and, not, eq, get,
|
|
7
|
-
} = require('rubico')
|
|
8
|
-
|
|
9
|
-
const identity = x => x
|
|
10
|
-
|
|
11
|
-
// [person] => Map { person => (Set { person }) }
|
|
12
|
-
const makeTracker = transform(
|
|
13
|
-
map(fork([
|
|
14
|
-
person => person,
|
|
15
|
-
() => new Set(),
|
|
16
|
-
])),
|
|
17
|
-
new Map(),
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
const db = new Map()
|
|
21
|
-
|
|
22
|
-
const saveTracker = async tracker => { db.set('tracker', tracker) }
|
|
23
|
-
|
|
24
|
-
const hasTracker = async () => db.has('tracker')
|
|
25
|
-
|
|
26
|
-
const getTracker = async tracker => db.get('tracker')
|
|
27
|
-
|
|
28
|
-
const isNotIn = set => x => !set.has(x)
|
|
29
|
-
|
|
30
|
-
// { people, tracker } => { people, tracker, pairs }
|
|
31
|
-
const algorithm = ({ people, tracker }) => {
|
|
32
|
-
const matchedThisRound = new Set()
|
|
33
|
-
return fork({
|
|
34
|
-
people: identity,
|
|
35
|
-
tracker: () => tracker,
|
|
36
|
-
pairs: transform(
|
|
37
|
-
pipe([
|
|
38
|
-
filter(isNotIn(matchedThisRound)),
|
|
39
|
-
map(person => {
|
|
40
|
-
for (const other of people) {
|
|
41
|
-
// console.log('person:other', `${person}:${other}`)
|
|
42
|
-
if (other === person) continue
|
|
43
|
-
if (tracker.get(person).has(other)) continue
|
|
44
|
-
if (matchedThisRound.has(other)) continue
|
|
45
|
-
tracker.get(person).add(other)
|
|
46
|
-
tracker.get(other).add(person)
|
|
47
|
-
matchedThisRound.add(person)
|
|
48
|
-
matchedThisRound.add(other)
|
|
49
|
-
return [person, other]
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
filter(Array.isArray),
|
|
53
|
-
]),
|
|
54
|
-
[],
|
|
55
|
-
)
|
|
56
|
-
})(people)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// [person, person, person, person, ...] => [[person, person], [person, person], ...]
|
|
60
|
-
const matchmake = pipe([
|
|
61
|
-
fork({
|
|
62
|
-
people: identity,
|
|
63
|
-
tracker: switchCase([
|
|
64
|
-
hasTracker, getTracker,
|
|
65
|
-
makeTracker,
|
|
66
|
-
]),
|
|
67
|
-
}),
|
|
68
|
-
algorithm,
|
|
69
|
-
tap(pipe([get('tracker'), saveTracker])),
|
|
70
|
-
])
|
|
71
|
-
|
|
72
|
-
const didEveryoneMatch = (tracker, people) => {
|
|
73
|
-
for (const [, set] of tracker) {
|
|
74
|
-
if (set.size < people.length - 1) return false // 1 for yourself
|
|
75
|
-
}
|
|
76
|
-
return true
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const makePeople = number => Array.from((function*() {
|
|
80
|
-
for (let i = 0; i < number; i++) yield `${i + 1}`
|
|
81
|
-
})())
|
|
82
|
-
|
|
83
|
-
const main = async () => {
|
|
84
|
-
const people = makePeople(99)
|
|
85
|
-
console.log('people', people)
|
|
86
|
-
let i = 0
|
|
87
|
-
while (true) {
|
|
88
|
-
const round = await matchmake(people)
|
|
89
|
-
const { tracker, pairs } = round
|
|
90
|
-
console.log('round', i, pairs)
|
|
91
|
-
if (didEveryoneMatch(tracker, people)) break
|
|
92
|
-
i += 1
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
main()
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { pipe, tap, map, transform } = require('..')
|
|
4
|
-
const request = require('request')
|
|
5
|
-
|
|
6
|
-
const urls = [
|
|
7
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fforceum.json?alt=media&token=ed9db67c-d744-414f-8812-21cfbba63447',
|
|
8
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fgood-year.json?alt=media&token=1131b553-e2e5-4ff6-87cb-f346e57e389e',
|
|
9
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fgt-radial.json?alt=media&token=d2ba3f51-cef7-494e-8006-61d321d677cd',
|
|
10
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fkpatos.json?alt=media&token=75743c44-1521-4ff4-8133-e56a474f7c3e',
|
|
11
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fland-spider.json?alt=media&token=22a3aa7b-18a9-4bd1-b34b-5ae48cadbc55',
|
|
12
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fleao-tires.json?alt=media&token=84dcc7f8-de32-46a9-9aae-854639772975',
|
|
13
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fwanli.json?alt=media&token=4bb13f3a-5d9a-4c2d-b558-964ee996a534',
|
|
14
|
-
'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fzeta.json?alt=media&token=c04f973c-2577-4f06-805e-68e46480e9ae'
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
const getFile = url => new Promise((resolve, reject) => {
|
|
18
|
-
request({
|
|
19
|
-
uri: url,
|
|
20
|
-
method: "GET",
|
|
21
|
-
gzip: true,
|
|
22
|
-
qs: { format: "json" },
|
|
23
|
-
}, (err, resp, body) => err ? reject(err) : resolve(body))
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// urls => tire_json_data
|
|
27
|
-
const download_tire_json_from_firebase = map(getFile)
|
|
28
|
-
|
|
29
|
-
const main = async () => {
|
|
30
|
-
const data = await transform(pipe([
|
|
31
|
-
map(getFile),
|
|
32
|
-
tap(console.log),
|
|
33
|
-
]), [])(urls)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
main()
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { pipe, fork, map, reduce, get } = require('..')
|
|
4
|
-
|
|
5
|
-
const data = { "Office": {
|
|
6
|
-
"California" : {
|
|
7
|
-
"Contract1": {
|
|
8
|
-
1: {Price: 1000, Count: 5}, 2: {Price: 2000, Count: 11},
|
|
9
|
-
3: {Price: 3000, Count: 3}, 4: {Price: 2000, Count: 1},
|
|
10
|
-
5: {Price: 1000, Count: 5}, 6: {Price: 2000, Count: 11},
|
|
11
|
-
7: {Price: 3000, Count: 3}, 8: {Price: 2000, Count: 1},
|
|
12
|
-
9: {Price: 1000, Count: 5}, 10: {Price: 2000, Count: 11},
|
|
13
|
-
11: {Price: 3000, Count: 3}, 12: {Price: 2000, Count: 1},
|
|
14
|
-
},
|
|
15
|
-
"Contract2": {
|
|
16
|
-
1: {Price: 7000, Count: 6}, 2: {Price: 1000, Count: 4},
|
|
17
|
-
3: {Price: 67000, Count: 6}, 4: {Price: 500, Count: 2},
|
|
18
|
-
5: {Price: 7000, Count: 6}, 6: {Price: 1000, Count: 4},
|
|
19
|
-
7: {Price: 67000, Count: 6}, 8: {Price: 500, Count: 2},
|
|
20
|
-
9: {Price: 7000, Count: 6}, 10: {Price: 1000, Count: 4},
|
|
21
|
-
11: {Price: 67000, Count: 6}, 12: {Price: 500, Count: 2},
|
|
22
|
-
},
|
|
23
|
-
"Contract3": {
|
|
24
|
-
1: {Price: 4000, Count: 4}, 2: {Price: 4000, Count: 1},
|
|
25
|
-
3: {Price: 5000, Count: 12}, 4: {Price: 5000, Count: 2},
|
|
26
|
-
5: {Price: 4000, Count: 4}, 6: {Price: 4000, Count: 1},
|
|
27
|
-
7: {Price: 5000, Count: 12}, 8: {Price: 5000, Count: 2},
|
|
28
|
-
9: {Price: 4000, Count: 4}, 10: {Price: 4000, Count: 1},
|
|
29
|
-
11: {Price: 5000, Count: 12}, 12: {Price: 5000, Count: 2},
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"North Carolina" : {
|
|
33
|
-
"Contract1": {
|
|
34
|
-
1: {Price: 7000, Count: 4}, 2: {Price: 7000, Count: 4},
|
|
35
|
-
3: {Price: 7000, Count: 4}, 4: {Price: 7000, Count: 4},
|
|
36
|
-
5: {Price: 7000, Count: 4}, 6: {Price: 7000, Count: 4},
|
|
37
|
-
7: {Price: 7000, Count: 4}, 8: {Price: 7000, Count: 4},
|
|
38
|
-
9: {Price: 7000, Count: 4}, 10: {Price: 7000, Count: 4},
|
|
39
|
-
11: {Price: 7000, Count: 4}, 12: {Price: 7000, Count: 4},
|
|
40
|
-
},
|
|
41
|
-
"Contract2": {
|
|
42
|
-
1: {Price: 6000, Count: 4}, 2: {Price: 2000, Count: 10},
|
|
43
|
-
3: {Price: 3000, Count: 3}, 4: {Price: 2000, Count: 3},
|
|
44
|
-
5: {Price: 6000, Count: 4}, 6: {Price: 2000, Count: 10},
|
|
45
|
-
7: {Price: 3000, Count: 3}, 8: {Price: 2000, Count: 3},
|
|
46
|
-
9: {Price: 6000, Count: 4}, 10: {Price: 2000, Count: 10},
|
|
47
|
-
11: {Price: 3000, Count: 3}, 12: {Price: 2000, Count: 3},
|
|
48
|
-
},
|
|
49
|
-
"Contract3": {
|
|
50
|
-
1: {Price: 4000, Count: 5}, 2: {Price: 2000, Count: 4},
|
|
51
|
-
3: {Price: 4000, Count: 3}, 4: {Price: 2000, Count: 4},
|
|
52
|
-
5: {Price: 4000, Count: 5}, 6: {Price: 2000, Count: 4},
|
|
53
|
-
7: {Price: 4000, Count: 3}, 8: {Price: 2000, Count: 4},
|
|
54
|
-
9: {Price: 4000, Count: 5}, 10: {Price: 2000, Count: 4},
|
|
55
|
-
11: {Price: 4000, Count: 3}, 12: {Price: 2000, Count: 4},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
} }
|
|
59
|
-
|
|
60
|
-
const addContracts = (total, contract) => ({
|
|
61
|
-
Price: total.Price + contract.Price,
|
|
62
|
-
Count: total.Count + contract.Count,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const monthNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
|
66
|
-
|
|
67
|
-
const sumMonthsToQuarters = contract => {
|
|
68
|
-
const quartered = {
|
|
69
|
-
1: { Price: 0, Count: 0 },
|
|
70
|
-
2: { Price: 0, Count: 0 },
|
|
71
|
-
3: { Price: 0, Count: 0 },
|
|
72
|
-
4: { Price: 0, Count: 0 },
|
|
73
|
-
}
|
|
74
|
-
for (const monthNum of monthNumbers) {
|
|
75
|
-
const quarterNum = Math.ceil(monthNum / 3)
|
|
76
|
-
quartered[quarterNum] = addContracts(quartered[quarterNum], contract[monthNum])
|
|
77
|
-
}
|
|
78
|
-
return quartered
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const x = map(map(map(sumMonthsToQuarters)))(data)
|
|
82
|
-
|
|
83
|
-
console.log(JSON.stringify(x))
|
|
84
|
-
|
|
85
|
-
// https://stackoverflow.com/questions/62103014/reducing-a-nested-object-in-javascript/62110877
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S deno run
|
|
2
|
-
|
|
3
|
-
import { map, filter, pipe } from '../rubico.js'
|
|
4
|
-
|
|
5
|
-
const isOdd = (x: number): boolean => x % 2 === 1
|
|
6
|
-
|
|
7
|
-
const square = (x: number): number => x ** 2
|
|
8
|
-
|
|
9
|
-
const squaredOdds = pipe([
|
|
10
|
-
filter(isOdd),
|
|
11
|
-
map(square),
|
|
12
|
-
])
|
|
13
|
-
|
|
14
|
-
console.log(
|
|
15
|
-
squaredOdds([1, 2, 3, 4, 5]), // [1, 9, 25]
|
|
16
|
-
)
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// from https://stackoverflow.com/questions/62074394/filter-array-and-get-max-values-of-nested-array-of-each-set-of-objects-in-javas/62077548#62077548
|
|
4
|
-
|
|
5
|
-
const { transform, pipe, assign, tap, map, filter, reduce, get, gt } = require('rubico')
|
|
6
|
-
|
|
7
|
-
const data = [
|
|
8
|
-
{
|
|
9
|
-
product: 'laptop',
|
|
10
|
-
count_buyer: 3,
|
|
11
|
-
buyers: [
|
|
12
|
-
{ name: 'Vins', purchase_amount: 27 },
|
|
13
|
-
{ name: 'Jan', purchase_amount: 38 },
|
|
14
|
-
{ name: 'Alex', purchase_amount: 80 },
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
product: 'televisor',
|
|
19
|
-
count_buyer: 2,
|
|
20
|
-
buyers: [
|
|
21
|
-
{ name: 'Carl', purchase_amount: 25 },
|
|
22
|
-
{ name: 'Digi', purchase_amount: 40 }
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
product: 'ropa varon',
|
|
27
|
-
count_buyer: 0,
|
|
28
|
-
buyers: [],
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const getMaxBuyer = (y, xi) => y.purchase_amount > xi.purchase_amount ? y : xi
|
|
33
|
-
|
|
34
|
-
const getProductsWithMaxBuyer = pipe([
|
|
35
|
-
filter(gt(get('buyers.length'), 0)), // filter for products with buyers.length > 0
|
|
36
|
-
tap(x => console.log('tap', x)),
|
|
37
|
-
map(assign({
|
|
38
|
-
buyers: pipe([
|
|
39
|
-
get('buyers'), // product => product.buyers
|
|
40
|
-
reduce(getMaxBuyer), // buyers => [max_buyer]
|
|
41
|
-
]),
|
|
42
|
-
})),
|
|
43
|
-
tap(x => console.log('tap', x)),
|
|
44
|
-
])
|
|
45
|
-
|
|
46
|
-
console.log('intermediate arrays, should see 2 arrays')
|
|
47
|
-
|
|
48
|
-
getProductsWithMaxBuyer(data) /* > [
|
|
49
|
-
{
|
|
50
|
-
product: 'laptop',
|
|
51
|
-
count_buyer: 3,
|
|
52
|
-
buyers: { name: 'Alex', purchase_amount: 80 }
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
product: 'televisor',
|
|
56
|
-
count_buyer: 2,
|
|
57
|
-
buyers: { name: 'Digi', purchase_amount: 40 }
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
console.log('one pass, should see 4 products individually')
|
|
63
|
-
|
|
64
|
-
transform(
|
|
65
|
-
getProductsWithMaxBuyer,
|
|
66
|
-
[],
|
|
67
|
-
)(data)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const { pipe, map, transform } = require('rubico')
|
|
2
|
-
const fetch = require('node-fetch')
|
|
3
|
-
|
|
4
|
-
const toTodosUrl = id => 'https://jsonplaceholder.typicode.com/todos/' + id
|
|
5
|
-
|
|
6
|
-
const fetchedToJson = fetched => fetched.json()
|
|
7
|
-
|
|
8
|
-
const fetchTodo = pipe([
|
|
9
|
-
toTodosUrl,
|
|
10
|
-
fetch,
|
|
11
|
-
fetchedToJson,
|
|
12
|
-
])
|
|
13
|
-
|
|
14
|
-
const Stdout = {
|
|
15
|
-
concat(...args) {
|
|
16
|
-
console.log(...args)
|
|
17
|
-
return this
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const todoIDsRange = function* (from, to) {
|
|
22
|
-
for (let id = from; id <= to; id++) {
|
|
23
|
-
yield id
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const logTodosRange = transform(
|
|
28
|
-
map(fetchTodo), Stdout,
|
|
29
|
-
)(todoIDsRange)
|
|
30
|
-
|
|
31
|
-
logTodosRange(1, 100)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { pipe, map, transform } = require('..')
|
|
4
|
-
|
|
5
|
-
const square = number => number ** 2
|
|
6
|
-
|
|
7
|
-
const toString = value => value.toString()
|
|
8
|
-
|
|
9
|
-
const randomInt = () => Math.ceil(Math.random() * 100)
|
|
10
|
-
|
|
11
|
-
const streamRandomInts = async function* () {
|
|
12
|
-
while (true) {
|
|
13
|
-
yield randomInt()
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
transform(
|
|
18
|
-
map(pipe([square, toString])), process.stdout,
|
|
19
|
-
)(streamRandomInts())
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name callChain
|
|
3
|
-
*
|
|
4
|
-
* @synopsis
|
|
5
|
-
* Monad = { chain: function }
|
|
6
|
-
*
|
|
7
|
-
* callChain(monad Monad, resolver)
|
|
8
|
-
const callChain = (monad, resolver) => monad.chain(resolver)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @name arrayPushIf
|
|
13
|
-
*
|
|
14
|
-
* @synopsis
|
|
15
|
-
* arrayPushIf(predicate, any=>boolean, array Array, item any) -> ()
|
|
16
|
-
*/
|
|
17
|
-
const arrayPushIf = function (predicate, array, item) {
|
|
18
|
-
if (predicate(item)) {
|
|
19
|
-
array.push(item)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @name forEachReduceConcurrent
|
|
25
|
-
*
|
|
26
|
-
* @synopsis
|
|
27
|
-
* forEachReduceConcurrent(
|
|
28
|
-
* collection { forEach: function },
|
|
29
|
-
* reducer (any, T)=>Promise|any,
|
|
30
|
-
* result any,
|
|
31
|
-
* ) -> Promise|result
|
|
32
|
-
*/
|
|
33
|
-
const forEachReduceConcurrent = function (collection, reducer, result) {
|
|
34
|
-
const promises = [],
|
|
35
|
-
getResult = () => result
|
|
36
|
-
collection.forEach(funcConcatSync(
|
|
37
|
-
curry2(reducer, result, __),
|
|
38
|
-
curry3(arrayPushIf, isPromise, promises, __)))
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
collection.forEach([
|
|
42
|
-
tap(item => console.log('heyo', reducer, result, item)),
|
|
43
|
-
curry2(reducer, result, __),
|
|
44
|
-
curry3(arrayPushIf, isPromise, promises, __),
|
|
45
|
-
].reduce(funcConcatSync))
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
return promises.length == 0
|
|
49
|
-
? result
|
|
50
|
-
: promiseAll(promises).then(getResult)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @name iterableReduceConcurrent
|
|
55
|
-
*
|
|
56
|
-
* @synopsis
|
|
57
|
-
* iterableReduceConcurrent(
|
|
58
|
-
* iterable { [Symbol.iterator]: function },
|
|
59
|
-
* reducer (any, T)=>Promise|any,
|
|
60
|
-
* result any,
|
|
61
|
-
* ) -> Promise|result
|
|
62
|
-
*/
|
|
63
|
-
const iterableReduceConcurrent = function (iterable, reducer, result) {
|
|
64
|
-
const promises = [],
|
|
65
|
-
getResult = () => result,
|
|
66
|
-
pipeline = funcConcatSync(
|
|
67
|
-
curry2(reducer, result, __),
|
|
68
|
-
curry3(arrayPushIf, isPromise, promises, __))
|
|
69
|
-
|
|
70
|
-
for (const item of iterable) {
|
|
71
|
-
pipeline(item)
|
|
72
|
-
}
|
|
73
|
-
return promises.length == 0
|
|
74
|
-
? result
|
|
75
|
-
: promiseAll(promises).then(getResult)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @name asyncIterableReduceConcurrent
|
|
80
|
-
*
|
|
81
|
-
* @synopsis
|
|
82
|
-
* asyncIterableReduceConcurrent(
|
|
83
|
-
* asyncIterable { [Symbol.iterator]: function },
|
|
84
|
-
* reducer (any, T)=>Promise|any,
|
|
85
|
-
* result any,
|
|
86
|
-
* ) -> Promise|result
|
|
87
|
-
*/
|
|
88
|
-
const asyncIterableReduceConcurrent = async function (asyncIterable, reducer, result) {
|
|
89
|
-
const promises = [],
|
|
90
|
-
getResult = () => result,
|
|
91
|
-
pipeline = funcConcatSync(
|
|
92
|
-
curry2(reducer, result, __),
|
|
93
|
-
curry3(arrayPushIf, isPromise, promises, __))
|
|
94
|
-
|
|
95
|
-
for await (const item of asyncIterable) {
|
|
96
|
-
pipeline(item)
|
|
97
|
-
}
|
|
98
|
-
return promises.length == 0
|
|
99
|
-
? result
|
|
100
|
-
: promiseAll(promises).then(getResult)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @name objectReduceConcurrent
|
|
105
|
-
*
|
|
106
|
-
* @synopsis
|
|
107
|
-
* objectReduceConcurrent(
|
|
108
|
-
* object Object,
|
|
109
|
-
* reducer (any, T)=>Promise|any,
|
|
110
|
-
* result any,
|
|
111
|
-
* ) -> Promise|result
|
|
112
|
-
*
|
|
113
|
-
* @related objectFlatMap
|
|
114
|
-
*/
|
|
115
|
-
const objectReduceConcurrent = function (object, reducer, result) {
|
|
116
|
-
const promises = [],
|
|
117
|
-
getResult = () => result,
|
|
118
|
-
pipeline = funcConcatSync(
|
|
119
|
-
curry2(reducer, result, __),
|
|
120
|
-
curry3(arrayPushIf, isPromise, promises, __))
|
|
121
|
-
|
|
122
|
-
for (const key in object) {
|
|
123
|
-
pipeline(object[key])
|
|
124
|
-
}
|
|
125
|
-
return promises.length == 0
|
|
126
|
-
? result
|
|
127
|
-
: promiseAll(promises).then(getResult)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @name getArg1
|
|
132
|
-
*
|
|
133
|
-
* @synopsis
|
|
134
|
-
* getArg1(arg0 any, arg1 any) -> arg1
|
|
135
|
-
*/
|
|
136
|
-
const getArg1 = function (arg0, arg1) {
|
|
137
|
-
return arg1
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @name foldableReduceConcurrent
|
|
142
|
-
*
|
|
143
|
-
* @synopsis
|
|
144
|
-
* foldableReduceConcurrent(
|
|
145
|
-
* foldable { reduce: function },
|
|
146
|
-
* reducer (any, T)=>Promise|any,
|
|
147
|
-
* result any,
|
|
148
|
-
* ) -> Promise|result
|
|
149
|
-
*/
|
|
150
|
-
const foldableReduceConcurrent = function (foldable, reducer, result) {
|
|
151
|
-
const promises = [],
|
|
152
|
-
getResult = () => result,
|
|
153
|
-
pipeline = [
|
|
154
|
-
getArg1,
|
|
155
|
-
curry2(reducer, result, __),
|
|
156
|
-
curry3(arrayPushIf, isPromise, promises, __),
|
|
157
|
-
].reduce(funcConcatSync)
|
|
158
|
-
|
|
159
|
-
foldable.reduce(tapSync(pipeline), null)
|
|
160
|
-
return promises.length == 0
|
|
161
|
-
? result
|
|
162
|
-
: promiseAll(promises).then(getResult)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @name tacitGenericReduceConcurrent
|
|
167
|
-
*
|
|
168
|
-
* @synopsis
|
|
169
|
-
* any -> T
|
|
170
|
-
*
|
|
171
|
-
* tacitGenericReduceConcurrent(
|
|
172
|
-
* reducer (any, T)=>any,
|
|
173
|
-
* result any,
|
|
174
|
-
* ) -> reducing ...any=>result
|
|
175
|
-
*/
|
|
176
|
-
const tacitGenericReduceConcurrent = (
|
|
177
|
-
reducer, result,
|
|
178
|
-
) => function reducing(...args) {
|
|
179
|
-
return genericReduceConcurrent(args, reducer, result)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @name genericReduceConcurrent
|
|
184
|
-
*
|
|
185
|
-
* @synopsis
|
|
186
|
-
* genericReduceConcurrent(
|
|
187
|
-
* args Array,
|
|
188
|
-
* reducer function,
|
|
189
|
-
* result any,
|
|
190
|
-
* ) -> result
|
|
191
|
-
*
|
|
192
|
-
* @related
|
|
193
|
-
* genericReduce
|
|
194
|
-
*
|
|
195
|
-
* @NOTE
|
|
196
|
-
* concurrency is only possible because result is never reassigned. in that regard, `result` is required.
|
|
197
|
-
*/
|
|
198
|
-
const genericReduceConcurrent = function (args, reducer, result) {
|
|
199
|
-
const collection = args[0]
|
|
200
|
-
if (collection == null) {
|
|
201
|
-
reducer(result, collection)
|
|
202
|
-
return result
|
|
203
|
-
}
|
|
204
|
-
if (typeof collection.forEach == 'function') {
|
|
205
|
-
return forEachReduceConcurrent(collection, reducer, result)
|
|
206
|
-
}
|
|
207
|
-
if (typeof collection[symbolIterator] == 'function') {
|
|
208
|
-
return iterableReduceConcurrent(collection, reducer, result)
|
|
209
|
-
}
|
|
210
|
-
if (typeof collection[symbolAsyncIterator] == 'function') {
|
|
211
|
-
return asyncIterableReduceConcurrent(collection, reducer, result)
|
|
212
|
-
}
|
|
213
|
-
if (typeof collection.reduce == 'function') {
|
|
214
|
-
return foldableReduceConcurrent(collection, reducer, result)
|
|
215
|
-
}
|
|
216
|
-
if (typeof collection.chain == 'function') {
|
|
217
|
-
return collection.chain(curry2(reducer, result, __))
|
|
218
|
-
}
|
|
219
|
-
if (typeof collection.flatMap == 'function') {
|
|
220
|
-
return collection.flatMap(curry2(reducer, result, __))
|
|
221
|
-
}
|
|
222
|
-
if (collection.constructor == Object) {
|
|
223
|
-
return objectReduceConcurrent(collection, reducer, result)
|
|
224
|
-
}
|
|
225
|
-
reducer(result, collection)
|
|
226
|
-
return result
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @name flatteningTransducerConcurrent
|
|
231
|
-
*
|
|
232
|
-
* @synopsis
|
|
233
|
-
* flatteningTransducerConcurrent(concat Reducer) -> flatteningReducer Reducer
|
|
234
|
-
*
|
|
235
|
-
* DuplexStream = { read: function, write: function }
|
|
236
|
-
*
|
|
237
|
-
* Monad = Array|String|Set
|
|
238
|
-
* |TypedArray|DuplexStream|Iterator|AsyncIterator
|
|
239
|
-
* |{ chain: function }|{ flatMap: function }|Object
|
|
240
|
-
*
|
|
241
|
-
* Foldable = Iterable|AsyncIterable|{ reduce: function }
|
|
242
|
-
*
|
|
243
|
-
* FlatteningReducer<T> = (any, T)=>Promise|Monad|Foldable|any
|
|
244
|
-
*
|
|
245
|
-
* Reducer<T> = (any, T)=>Promise|any
|
|
246
|
-
*
|
|
247
|
-
* flatteningTransducerConcurrent(concat Reducer) -> flatteningReducer FlatteningReducer
|
|
248
|
-
*
|
|
249
|
-
* @execution concurrent
|
|
250
|
-
*/
|
|
251
|
-
const flatteningTransducerConcurrent = concat => function flatteningReducer(
|
|
252
|
-
result, item,
|
|
253
|
-
) {
|
|
254
|
-
return genericReduceConcurrent([item], concat, result)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @name objectMapToArray
|
|
259
|
-
*
|
|
260
|
-
* @synopsis
|
|
261
|
-
* objectMapToArray(
|
|
262
|
-
* object Object, mapper function,
|
|
263
|
-
* ) -> Promise|Array
|
|
264
|
-
*
|
|
265
|
-
* @note order not guaranteed
|
|
266
|
-
*/
|
|
267
|
-
const objectMapToArray = function (object, mapper) {
|
|
268
|
-
const result = []
|
|
269
|
-
let isAsync = false
|
|
270
|
-
|
|
271
|
-
for (const key in object) {
|
|
272
|
-
const resultItem = mapper(object[key])
|
|
273
|
-
if (isPromise(resultItem)) isAsync = true
|
|
274
|
-
result.push(resultItem)
|
|
275
|
-
}
|
|
276
|
-
return isAsync ? promiseAll(result) : result
|
|
277
|
-
}
|