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
package/archive/test.v0.2.9.js
DELETED
|
@@ -1,2334 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const _ = require('.')
|
|
3
|
-
|
|
4
|
-
const ase = assert.strictEqual
|
|
5
|
-
|
|
6
|
-
const ade = assert.deepEqual
|
|
7
|
-
|
|
8
|
-
const aname = (x, s) => {
|
|
9
|
-
if (s !== x.name) {
|
|
10
|
-
const e = new Error(`wrong name: ${x.name} !== ${s}`)
|
|
11
|
-
Error.captureStackTrace(e, aname)
|
|
12
|
-
e.name = 'AssertionError'
|
|
13
|
-
throw e
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const writeStdout = process.stdout.write.bind(process.stdout)
|
|
18
|
-
|
|
19
|
-
const captureStdout = () => {
|
|
20
|
-
const ret = { output: '' }
|
|
21
|
-
process.stdout.write = (chunk, encoding, cb) => {
|
|
22
|
-
if (typeof chunk === 'string') ret.output += chunk
|
|
23
|
-
return writeStdout(chunk, encoding, cb)
|
|
24
|
-
}
|
|
25
|
-
return ret
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const releaseStdout = () => {
|
|
29
|
-
process.stdout.write = writeStdout
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const hi = x => x + 'hi'
|
|
33
|
-
|
|
34
|
-
const ho = async x => x + 'ho'
|
|
35
|
-
|
|
36
|
-
const hey = x => new Promise(res => setTimeout(() => res(x + 'hey'), 10))
|
|
37
|
-
|
|
38
|
-
const add = (a, b) => a + b
|
|
39
|
-
|
|
40
|
-
const add1 = x => add(1, x)
|
|
41
|
-
|
|
42
|
-
const delayedAdd1 = x => new Promise(res => setTimeout(() => res(add(1, x)), 10))
|
|
43
|
-
|
|
44
|
-
const range = (start, end) => {
|
|
45
|
-
const arr = Array(end - start)
|
|
46
|
-
for (let i = start; i < end; i++) arr[i - start] = i
|
|
47
|
-
return arr
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const isEven = x => x % 2 === 0
|
|
51
|
-
|
|
52
|
-
describe('rubico', () => {
|
|
53
|
-
describe('_.exists', () => {
|
|
54
|
-
aname(_.exists, 'exists')
|
|
55
|
-
it('=> true if x is not undefined or not null', async () => {
|
|
56
|
-
ase(_.exists(undefined), false)
|
|
57
|
-
ase(_.exists(null), false)
|
|
58
|
-
ase(_.exists(0), true)
|
|
59
|
-
ase(_.exists(''), true)
|
|
60
|
-
ase(_.exists({}), true)
|
|
61
|
-
ase(_.exists([]), true)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
describe('_.dne', () => {
|
|
66
|
-
aname(_.dne, 'dne')
|
|
67
|
-
it('=> true if x is undefined or null', async () => {
|
|
68
|
-
ase(_.dne(undefined), true)
|
|
69
|
-
ase(_.dne(null), true)
|
|
70
|
-
ase(_.dne(0), false)
|
|
71
|
-
ase(_.dne(''), false)
|
|
72
|
-
ase(_.dne({}), false)
|
|
73
|
-
ase(_.dne([]), false)
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe('_.isFn', () => {
|
|
78
|
-
aname(_.isFn, 'isFn')
|
|
79
|
-
it('=> true if point is a fn', async () => {
|
|
80
|
-
ase(_.isFn(() => {}), true)
|
|
81
|
-
ase(_.isFn(function () {}), true)
|
|
82
|
-
ase(_.isFn(async x => x.ho + 1), true)
|
|
83
|
-
ase(_.isFn(0), false)
|
|
84
|
-
ase(_.isFn([]), false)
|
|
85
|
-
ase(_.isFn({}), false)
|
|
86
|
-
ase(_.isFn(undefined), false)
|
|
87
|
-
ase(_.isFn(null), false)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
describe('_.isString', () => {
|
|
92
|
-
aname(_.isString, 'isString')
|
|
93
|
-
it('=> true if point is a string', async () => {
|
|
94
|
-
ase(_.isString('hey'), true)
|
|
95
|
-
ase(_.isString(''), true)
|
|
96
|
-
ase(_.isString(() => {}), false)
|
|
97
|
-
ase(_.isString(0), false)
|
|
98
|
-
ase(_.isString([]), false)
|
|
99
|
-
ase(_.isString({}), false)
|
|
100
|
-
ase(_.isString(null), false)
|
|
101
|
-
ase(_.isString(undefined), false)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
describe('_.isNumber', () => {
|
|
106
|
-
aname(_.isNumber, 'isNumber')
|
|
107
|
-
it('=> true if point is a number', async () => {
|
|
108
|
-
ase(_.isNumber(1), true)
|
|
109
|
-
ase(_.isNumber(0), true)
|
|
110
|
-
ase(_.isNumber(1.1), true)
|
|
111
|
-
ase(_.isNumber('hey'), false)
|
|
112
|
-
ase(_.isNumber(''), false)
|
|
113
|
-
ase(_.isNumber([]), false)
|
|
114
|
-
ase(_.isNumber({}), false)
|
|
115
|
-
ase(_.isNumber(null), false)
|
|
116
|
-
ase(_.isNumber(undefined), false)
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
describe('_.isBigInt', () => {
|
|
121
|
-
aname(_.isBigInt, 'isBigInt')
|
|
122
|
-
it('=> true if point is a big int', async () => {
|
|
123
|
-
ase(_.isBigInt(2n), true)
|
|
124
|
-
ase(_.isBigInt(1), false)
|
|
125
|
-
ase(_.isBigInt('hey'), false)
|
|
126
|
-
ase(_.isBigInt([]), false)
|
|
127
|
-
ase(_.isBigInt({}), false)
|
|
128
|
-
ase(_.isBigInt(null), false)
|
|
129
|
-
ase(_.isBigInt(undefined), false)
|
|
130
|
-
ase(_.isBigInt(), false)
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
describe('_.isBoolean', () => {
|
|
135
|
-
aname(_.isBoolean, 'isBoolean')
|
|
136
|
-
it('=> true if point is a bool', async () => {
|
|
137
|
-
ase(_.isBoolean(true), true)
|
|
138
|
-
ase(_.isBoolean(false), true)
|
|
139
|
-
ase(_.isBoolean(0), false)
|
|
140
|
-
ase(_.isBoolean([]), false)
|
|
141
|
-
ase(_.isBoolean({}), false)
|
|
142
|
-
ase(_.isBoolean(null), false)
|
|
143
|
-
ase(_.isBoolean(), false)
|
|
144
|
-
ase(_.isBoolean(undefined), false)
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
describe('_.isArray', () => {
|
|
149
|
-
aname(_.isArray, 'isArray')
|
|
150
|
-
it('=> true if point is an array', async () => {
|
|
151
|
-
ase(_.isArray([1, 2, 3]), true)
|
|
152
|
-
ase(_.isArray([]), true)
|
|
153
|
-
ase(_.isArray({}), false)
|
|
154
|
-
ase(_.isArray(1), false)
|
|
155
|
-
ase(_.isArray('hey'), false)
|
|
156
|
-
ase(_.isArray(() => {}), false)
|
|
157
|
-
ase(_.isArray(null), false)
|
|
158
|
-
ase(_.isArray(undefined), false)
|
|
159
|
-
})
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
describe('_.isObject', () => {
|
|
163
|
-
aname(_.isObject, 'isObject')
|
|
164
|
-
it('=> true if point is an object', async () => {
|
|
165
|
-
ase(_.isObject({ a: 1 }), true)
|
|
166
|
-
ase(_.isObject({}), true)
|
|
167
|
-
ase(_.isObject([]), false)
|
|
168
|
-
ase(_.isObject(new Set()), false)
|
|
169
|
-
ase(_.isObject(new Map()), false)
|
|
170
|
-
ase(_.isObject(Buffer.from('hey')), false)
|
|
171
|
-
ase(_.isObject(() => {}), false)
|
|
172
|
-
ase(_.isObject(function () {}), false)
|
|
173
|
-
ase(_.isObject('hey'), false)
|
|
174
|
-
ase(_.isObject(null), false)
|
|
175
|
-
ase(_.isObject(undefined), false)
|
|
176
|
-
})
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
describe('_.isSet', () => {
|
|
180
|
-
aname(_.isSet, 'isSet')
|
|
181
|
-
it('=> true if point is a set', async () => {
|
|
182
|
-
ase(_.isSet(new Set([1, 2, 3])), true)
|
|
183
|
-
ase(_.isSet(new Set([])), true)
|
|
184
|
-
ase(_.isSet([]), false)
|
|
185
|
-
ase(_.isSet({}), false)
|
|
186
|
-
ase(_.isSet(new Map([['a', 1]])), false)
|
|
187
|
-
ase(_.isSet(null), false)
|
|
188
|
-
ase(_.isSet(undefined), false)
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
describe('_.isMap', () => {
|
|
193
|
-
aname(_.isMap, 'isMap')
|
|
194
|
-
it('=> true if point is a map', async () => {
|
|
195
|
-
ase(_.isMap(new Map([['a', 1]])), true)
|
|
196
|
-
ase(_.isMap(new Map([])), true)
|
|
197
|
-
ase(_.isMap(new Set([])), false)
|
|
198
|
-
ase(_.isMap({}), false)
|
|
199
|
-
ase(_.isMap(null), false)
|
|
200
|
-
ase(_.isMap(undefined), false)
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
describe('_.isBuffer', () => {
|
|
205
|
-
aname(_.isBuffer, 'isBuffer')
|
|
206
|
-
it('=> true if point is a buffer', async () => {
|
|
207
|
-
ase(_.isBuffer(Buffer.from('abc')), true)
|
|
208
|
-
ase(_.isBuffer(Buffer.from('')), true)
|
|
209
|
-
ase(_.isBuffer(''), false)
|
|
210
|
-
ase(_.isBuffer([]), false)
|
|
211
|
-
ase(_.isBuffer({}), false)
|
|
212
|
-
ase(_.isBuffer(null), false)
|
|
213
|
-
ase(_.isBuffer(undefined), false)
|
|
214
|
-
})
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
describe('_.isSymbol', () => {
|
|
218
|
-
aname(_.isSymbol, 'isSymbol')
|
|
219
|
-
it('=> true if point is a symbol', async () => {
|
|
220
|
-
ase(_.isSymbol(Symbol()), true)
|
|
221
|
-
ase(_.isSymbol(([])[Symbol.iterator]), false)
|
|
222
|
-
ase(_.isSymbol('hey'), false)
|
|
223
|
-
ase(_.isSymbol(''), false)
|
|
224
|
-
ase(_.isSymbol(null), false)
|
|
225
|
-
ase(_.isSymbol(undefined), false)
|
|
226
|
-
})
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
describe('_.isPromise', () => {
|
|
230
|
-
aname(_.isPromise, 'isPromise')
|
|
231
|
-
it('=> true if point is a promise', async () => {
|
|
232
|
-
ase(_.isPromise(new Promise(res => res('hey'))), true)
|
|
233
|
-
ase(_.isPromise((async x => x)()), true)
|
|
234
|
-
ase(_.isPromise(1), false)
|
|
235
|
-
ase(_.isPromise(''), false)
|
|
236
|
-
ase(_.isPromise([]), false)
|
|
237
|
-
ase(_.isPromise({}), false)
|
|
238
|
-
ase(_.isPromise(null), false)
|
|
239
|
-
ase(_.isPromise(undefined), false)
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
describe('_.isRegExp', () => {
|
|
244
|
-
aname(_.isRegExp, 'isRegExp')
|
|
245
|
-
it('=> true if point is a regular expression', async () => {
|
|
246
|
-
ase(_.isRegExp(/hey/), true)
|
|
247
|
-
ase(_.isRegExp('hey'), false)
|
|
248
|
-
ase(_.isRegExp(null), false)
|
|
249
|
-
ase(_.isRegExp(undefined), false)
|
|
250
|
-
ase(_.isRegExp(), false)
|
|
251
|
-
})
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
describe('_.id', () => {
|
|
255
|
-
aname(_.id, 'id')
|
|
256
|
-
it('x => x', async () => {
|
|
257
|
-
ase(_.id(1), 1)
|
|
258
|
-
ase(_.id(1, 2, 3), 1)
|
|
259
|
-
})
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
describe('_.noop', () => {
|
|
263
|
-
aname(_.noop, 'noop')
|
|
264
|
-
it('does nothing', async () => {
|
|
265
|
-
ase(_.noop(Infinity), undefined)
|
|
266
|
-
})
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
describe('_.inspect', () => {
|
|
270
|
-
aname(_.inspect, 'inspect')
|
|
271
|
-
it('inspects with depth infinity', async () => {
|
|
272
|
-
ase(_.inspect(function hey(){}), '[Function: hey]')
|
|
273
|
-
ase(_.inspect(() => {}), '[Function]')
|
|
274
|
-
ase(_.inspect(1), '1')
|
|
275
|
-
ase(_.inspect('hey'), '\'hey\'')
|
|
276
|
-
ase(_.inspect(true), 'true')
|
|
277
|
-
ase(_.inspect([]), '[]')
|
|
278
|
-
ase(_.inspect({}), '{}')
|
|
279
|
-
ase(_.inspect(new Set()), 'Set {}')
|
|
280
|
-
ase(_.inspect(new Map()), 'Map {}')
|
|
281
|
-
})
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
describe('_.spread', () => {
|
|
285
|
-
aname(_.spread, 'spread')
|
|
286
|
-
aname(_.spread(add), 'spread(add)')
|
|
287
|
-
it('spreads args into fn', async () => {
|
|
288
|
-
ase(
|
|
289
|
-
_.spread((a, b) => a + b)([1, 2]),
|
|
290
|
-
3,
|
|
291
|
-
)
|
|
292
|
-
})
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
describe('_.throw', () => {
|
|
296
|
-
aname(_.throw, 'throw')
|
|
297
|
-
it('throws e', async () => {
|
|
298
|
-
assert.throws(
|
|
299
|
-
() => _.throw(new TypeError('hey')),
|
|
300
|
-
new TypeError('hey'),
|
|
301
|
-
)
|
|
302
|
-
})
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
describe('_.apply', () => {
|
|
306
|
-
const add3 = a => b => c => a + b + c
|
|
307
|
-
aname(_.apply, 'apply')
|
|
308
|
-
aname(_.apply(add3), 'apply(add3)')
|
|
309
|
-
it('applies an array of arguments to fn', async () => {
|
|
310
|
-
ase(
|
|
311
|
-
_.apply(add3)([1, 2, 3]),
|
|
312
|
-
6,
|
|
313
|
-
)
|
|
314
|
-
})
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
describe('_.shorthand', () => {
|
|
318
|
-
aname(_.shorthand, 'shorthand')
|
|
319
|
-
it('shorthands the types', async () => {
|
|
320
|
-
ase(_.shorthand(''), '\'\'')
|
|
321
|
-
ase(_.shorthand(_.id), 'id')
|
|
322
|
-
ase(_.shorthand('heyheyheyhey'), '\'heyheyheyh...\'{12}')
|
|
323
|
-
ase(_.shorthand('hey'), '\'hey\'')
|
|
324
|
-
ase(_.shorthand(2n), '2n')
|
|
325
|
-
ase(_.shorthand([]), '[]')
|
|
326
|
-
ase(_.shorthand([1, 2, 3]), '[...]{3}')
|
|
327
|
-
ase(_.shorthand({}), '{}')
|
|
328
|
-
ase(_.shorthand({ a: 1 }), '{...}{1}')
|
|
329
|
-
ase(_.shorthand(new Set()), 'Set{}')
|
|
330
|
-
ase(_.shorthand(new Set([1, 2, 3])), 'Set{...}{3}')
|
|
331
|
-
ase(_.shorthand(new Map()), 'Map{}')
|
|
332
|
-
ase(_.shorthand(new Map(Object.entries({ a: 1, b: 2 }))), 'Map{...}{2}')
|
|
333
|
-
ase(_.shorthand(Buffer.from('')), 'Buffer<>')
|
|
334
|
-
ase(_.shorthand(Buffer.from('hey')), 'Buffer<...>{3}')
|
|
335
|
-
ase(_.shorthand(Symbol()), 'Symbol()')
|
|
336
|
-
ase(_.shorthand(Symbol('hey')), 'Symbol(hey)')
|
|
337
|
-
ase(_.shorthand(/hey+/), '/hey\+/')
|
|
338
|
-
ase(_.shorthand(new Promise(res => res('hey'))), 'Promise { \'hey\' }')
|
|
339
|
-
})
|
|
340
|
-
})
|
|
341
|
-
|
|
342
|
-
describe('_.new', () => {
|
|
343
|
-
aname(_.new, 'new')
|
|
344
|
-
it('=> new default type', async () => {
|
|
345
|
-
ase(_.new('hey'), '')
|
|
346
|
-
ase(_.new(Infinity), 0)
|
|
347
|
-
ade(_.new([1, 2, 3]), [])
|
|
348
|
-
ade(_.new(new Set([1, 2, 3])), new Set())
|
|
349
|
-
ade(_.new(new Map([[1, 1], [2, 2]])), new Map())
|
|
350
|
-
ade(_.new({ a: 1, b: 2 }), {})
|
|
351
|
-
ade(_.new(Buffer.from('hey')), Buffer.from(''))
|
|
352
|
-
})
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
describe('_.copy', () => {
|
|
356
|
-
aname(_.copy, 'copy')
|
|
357
|
-
it('copies', async () => {
|
|
358
|
-
ase(_.copy('hey'), 'hey')
|
|
359
|
-
ase(_.copy(Infinity), Infinity)
|
|
360
|
-
ade(_.copy([1, 2, 3]), [1, 2, 3])
|
|
361
|
-
ade(_.copy(new Set([1, 2, 3])), new Set([1, 2, 3]))
|
|
362
|
-
ade(_.copy(new Map([[1, 1], [2, 2]])), new Map([[1, 1], [2, 2]]))
|
|
363
|
-
ade(_.copy({ a: 1, b: 2 }), { a: 1, b: 2 })
|
|
364
|
-
ade(_.copy(Buffer.from('hey')), Buffer.from('hey'))
|
|
365
|
-
})
|
|
366
|
-
})
|
|
367
|
-
|
|
368
|
-
describe('_.deepCopy', () => {
|
|
369
|
-
xit('deeply copies')
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
describe('_.toFn', () => {
|
|
373
|
-
aname(_.toFn, 'toFn')
|
|
374
|
-
aname(_.toFn(add), 'add')
|
|
375
|
-
aname(_.toFn(3), '() => 3')
|
|
376
|
-
aname(_.toFn('heyyyyyyyyyyyyy'), '() => \'heyyyyyyyy...\'{15}')
|
|
377
|
-
aname(_.toFn([1, 2, 3]), '() => [...]{3}')
|
|
378
|
-
it('coerces point to fn', async () => {
|
|
379
|
-
ase(_.toFn(() => {})(), undefined)
|
|
380
|
-
ase(await _.toFn(async () => 0)(), 0)
|
|
381
|
-
ase(_.toFn(1)(), 1)
|
|
382
|
-
ase(_.toFn(() => 0)(), 0)
|
|
383
|
-
ase(_.toFn(() => '')(), '')
|
|
384
|
-
ase(_.toFn(() => null)(), null)
|
|
385
|
-
ase(_.toFn(() => undefined)(), undefined)
|
|
386
|
-
})
|
|
387
|
-
})
|
|
388
|
-
|
|
389
|
-
describe('_.toString', () => {
|
|
390
|
-
aname(_.toString, 'toString')
|
|
391
|
-
it('coerces point to string', async () => {
|
|
392
|
-
ase(_.toString(x => x), 'x => x')
|
|
393
|
-
ase(_.toString('hey'), 'hey')
|
|
394
|
-
ase(_.toString(null), 'null')
|
|
395
|
-
ase(_.toString(undefined), 'undefined')
|
|
396
|
-
ase(_.toString({}), '[object Object]')
|
|
397
|
-
ase(_.toString([]), '')
|
|
398
|
-
ase(_.toString(1), '1')
|
|
399
|
-
})
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
describe('_.toInt', () => {
|
|
403
|
-
aname(_.toInt, 'toInt')
|
|
404
|
-
it('coerces point to number', async () => {
|
|
405
|
-
ase(_.toInt(1), 1)
|
|
406
|
-
ase(_.toInt('1'), 1)
|
|
407
|
-
ase(_.toInt('1.1'), 1)
|
|
408
|
-
ase(_.toInt(Infinity), Infinity)
|
|
409
|
-
ase(_.toInt(), NaN)
|
|
410
|
-
ase(_.toInt(null), NaN)
|
|
411
|
-
ase(_.toInt([]), NaN)
|
|
412
|
-
ase(_.toInt({}), NaN)
|
|
413
|
-
})
|
|
414
|
-
})
|
|
415
|
-
|
|
416
|
-
describe('_.toFloat', () => {
|
|
417
|
-
aname(_.toFloat, 'toFloat')
|
|
418
|
-
it('coerces point to number', async () => {
|
|
419
|
-
ase(_.toFloat(1), 1)
|
|
420
|
-
ase(_.toFloat(1.1), 1.1)
|
|
421
|
-
ase(_.toFloat('1'), 1)
|
|
422
|
-
ase(_.toFloat('1.1'), 1.1)
|
|
423
|
-
ase(_.toFloat(Infinity), Infinity)
|
|
424
|
-
ase(_.toFloat(), NaN)
|
|
425
|
-
ase(_.toFloat(null), NaN)
|
|
426
|
-
ase(_.toFloat([]), NaN)
|
|
427
|
-
ase(_.toFloat({}), NaN)
|
|
428
|
-
})
|
|
429
|
-
})
|
|
430
|
-
|
|
431
|
-
describe('_.toArray', () => {
|
|
432
|
-
aname(_.toArray, 'toArray')
|
|
433
|
-
it('coerces point to array', async () => {
|
|
434
|
-
ade(_.toArray(1), [1])
|
|
435
|
-
ade(_.toArray('hey'), ['hey'])
|
|
436
|
-
ade(_.toArray(''), [''])
|
|
437
|
-
ade(_.toArray(), [])
|
|
438
|
-
ade(_.toArray({}), [])
|
|
439
|
-
ade(_.toArray(new Set()), [])
|
|
440
|
-
ade(_.toArray(new Map()), [])
|
|
441
|
-
ade(_.toArray(new Map([])), [])
|
|
442
|
-
ade(_.toArray(null), [])
|
|
443
|
-
ade(_.toArray(undefined), [])
|
|
444
|
-
})
|
|
445
|
-
})
|
|
446
|
-
|
|
447
|
-
describe('_.toSet', () => {
|
|
448
|
-
aname(_.toSet, 'toSet')
|
|
449
|
-
it('coerces point to set', async () => {
|
|
450
|
-
ade(_.toSet([1, 2, 3]), new Set([1, 2, 3]))
|
|
451
|
-
ade(_.toSet([]), new Set())
|
|
452
|
-
ade(_.toSet(), new Set())
|
|
453
|
-
ade(_.toSet(1), new Set([1]))
|
|
454
|
-
ade(_.toSet('hey'), new Set(['hey']))
|
|
455
|
-
ade(_.toSet(null), new Set([]))
|
|
456
|
-
ade(_.toSet(undefined), new Set([]))
|
|
457
|
-
})
|
|
458
|
-
})
|
|
459
|
-
|
|
460
|
-
describe('_.toRegExp', () => {
|
|
461
|
-
aname(_.toRegExp, 'toRegExp')
|
|
462
|
-
it('coerces point to a regular expression', async () => {
|
|
463
|
-
ade(_.toRegExp('hey'), /hey/)
|
|
464
|
-
ade(_.toRegExp('(hey+ho)'), /\(hey\+ho\)/)
|
|
465
|
-
ade(_.toRegExp('hey', 'gi'), /hey/gi)
|
|
466
|
-
ade(_.toRegExp(/hey/), /hey/)
|
|
467
|
-
ade(_.toRegExp(/hey/, 'gi'), /hey/gi)
|
|
468
|
-
ade(_.toRegExp(/hey/g, 'gi'), /hey/gi)
|
|
469
|
-
})
|
|
470
|
-
it('throws TypeError', async () => {
|
|
471
|
-
assert.throws(
|
|
472
|
-
() => _.toRegExp(),
|
|
473
|
-
new TypeError('cannot coerce to RegExp undefined')
|
|
474
|
-
)
|
|
475
|
-
})
|
|
476
|
-
})
|
|
477
|
-
|
|
478
|
-
describe('_.flow', () => {
|
|
479
|
-
aname(_.flow, 'flow')
|
|
480
|
-
aname(_.flow(hi, ho, hey), 'hi→ho→hey')
|
|
481
|
-
it('chains async and regular functions together', async () => {
|
|
482
|
-
ase(await _.flow(hi, ho, hey)('yo'), 'yohihohey')
|
|
483
|
-
})
|
|
484
|
-
it('does something without arguments', async () => {
|
|
485
|
-
ase(await _.flow(hi, ho, hey)(), 'undefinedhihohey')
|
|
486
|
-
})
|
|
487
|
-
it('chaining one fn is the same as just calling that fn', async () => {
|
|
488
|
-
ase(await _.flow(hey)('yo'), await hey('yo'))
|
|
489
|
-
})
|
|
490
|
-
it('chaining no fns is identity', async () => {
|
|
491
|
-
ase(await _.flow()('yo'), 'yo')
|
|
492
|
-
})
|
|
493
|
-
it('throw a meaningful error on non functions', async () => {
|
|
494
|
-
assert.throws(
|
|
495
|
-
() => {
|
|
496
|
-
_.flow(() => 1, undefined, () => 2)
|
|
497
|
-
},
|
|
498
|
-
new TypeError('not all fns are fns'),
|
|
499
|
-
)
|
|
500
|
-
})
|
|
501
|
-
})
|
|
502
|
-
|
|
503
|
-
describe('_.flow.sync', () => {
|
|
504
|
-
aname(_.flow.sync, 'flow')
|
|
505
|
-
aname(_.flow.sync(hi, hi, hi), 'hi→hi→hi')
|
|
506
|
-
it('chains regular functions only', async () => {
|
|
507
|
-
ase(_.flow.sync(hi, hi, hi)('hi'), 'hihihihi')
|
|
508
|
-
})
|
|
509
|
-
it('throw a meaningful error on non functions', async () => {
|
|
510
|
-
assert.throws(
|
|
511
|
-
() => {
|
|
512
|
-
_.flow.sync(() => 1, undefined, () => 2)
|
|
513
|
-
},
|
|
514
|
-
new TypeError('not all fns are fns'),
|
|
515
|
-
)
|
|
516
|
-
})
|
|
517
|
-
})
|
|
518
|
-
|
|
519
|
-
describe('_.series', () => {
|
|
520
|
-
aname(_.series, 'series')
|
|
521
|
-
aname(_.series(hi, ho, hey), 'series(hi, ho, hey)')
|
|
522
|
-
it('supplies arguments to fns in series => [computed results]', async () => {
|
|
523
|
-
ade(
|
|
524
|
-
await _.series(hi, ho, hey)('yo'),
|
|
525
|
-
['yohi', 'yoho', 'yohey'],
|
|
526
|
-
)
|
|
527
|
-
})
|
|
528
|
-
it('throw a meaningful error on non functions', async () => {
|
|
529
|
-
assert.throws(
|
|
530
|
-
() => _.series(() => 1, undefined, () => 2),
|
|
531
|
-
new TypeError('not all fns are fns'),
|
|
532
|
-
)
|
|
533
|
-
})
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
describe('_.series.sync', () => {
|
|
537
|
-
aname(_.series.sync, 'series')
|
|
538
|
-
aname(_.series.sync(hi, ho, hey), 'series(hi, ho, hey)')
|
|
539
|
-
it('supplies arguments to sync fns in series => [computed results]', async () => {
|
|
540
|
-
ade(
|
|
541
|
-
await _.series(hi, ho, hey)('yo'),
|
|
542
|
-
['yohi', 'yoho', 'yohey'],
|
|
543
|
-
)
|
|
544
|
-
})
|
|
545
|
-
it('throw a meaningful error on non functions', async () => {
|
|
546
|
-
assert.throws(
|
|
547
|
-
() => {
|
|
548
|
-
_.series.sync(() => 1, undefined, () => 2)
|
|
549
|
-
},
|
|
550
|
-
new TypeError('not all fns are fns')
|
|
551
|
-
)
|
|
552
|
-
})
|
|
553
|
-
})
|
|
554
|
-
|
|
555
|
-
describe('_.switch', () => {
|
|
556
|
-
aname(_.switch, 'switch')
|
|
557
|
-
aname(_.switch(_.exists, hi, ho), 'switch(exists, hi, ho)')
|
|
558
|
-
it('switch case using fn order', async () => {
|
|
559
|
-
ase(
|
|
560
|
-
await _.switch(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(1),
|
|
561
|
-
'hey',
|
|
562
|
-
)
|
|
563
|
-
ase(
|
|
564
|
-
await _.switch(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(2),
|
|
565
|
-
'ho',
|
|
566
|
-
)
|
|
567
|
-
ase(
|
|
568
|
-
await _.switch(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(100),
|
|
569
|
-
'yo',
|
|
570
|
-
)
|
|
571
|
-
})
|
|
572
|
-
it('requires odd number of fns', async () => {
|
|
573
|
-
assert.throws(
|
|
574
|
-
() => _.switch(x => x, x => x, x => x, x => x),
|
|
575
|
-
new Error('odd number of fns required'),
|
|
576
|
-
)
|
|
577
|
-
})
|
|
578
|
-
it('requires 3 or more fns', async () => {
|
|
579
|
-
assert.throws(
|
|
580
|
-
() => _.switch(x => x),
|
|
581
|
-
new Error('3 or more fns required'),
|
|
582
|
-
)
|
|
583
|
-
})
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
describe('_.switch.sync', () => {
|
|
587
|
-
aname(_.switch.sync, 'switch')
|
|
588
|
-
aname(_.switch.sync(_.exists, hi, ho), 'switch(exists, hi, ho)')
|
|
589
|
-
it('switch case using sync fn order', async () => {
|
|
590
|
-
ase(
|
|
591
|
-
_.switch.sync(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(1),
|
|
592
|
-
'hey',
|
|
593
|
-
)
|
|
594
|
-
ase(
|
|
595
|
-
_.switch.sync(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(2),
|
|
596
|
-
'ho',
|
|
597
|
-
)
|
|
598
|
-
ase(
|
|
599
|
-
_.switch.sync(x => x === 1, 'hey', x => x === 2, 'ho', 'yo')(100),
|
|
600
|
-
'yo',
|
|
601
|
-
)
|
|
602
|
-
})
|
|
603
|
-
it('requires odd number of fns', async () => {
|
|
604
|
-
assert.throws(
|
|
605
|
-
() => _.switch.sync(x => x, x => x, x => x, x => x),
|
|
606
|
-
new Error('odd number of fns required'),
|
|
607
|
-
)
|
|
608
|
-
})
|
|
609
|
-
it('requires 3 or more fns', async () => {
|
|
610
|
-
assert.throws(
|
|
611
|
-
() => _.switch.sync(x => x),
|
|
612
|
-
new Error('3 or more fns required'),
|
|
613
|
-
)
|
|
614
|
-
})
|
|
615
|
-
})
|
|
616
|
-
|
|
617
|
-
describe('_.effect', () => {
|
|
618
|
-
aname(_.effect, 'effect')
|
|
619
|
-
aname(_.effect(hey), 'effect(hey)')
|
|
620
|
-
it('executes fn and returns first argument', async () => {
|
|
621
|
-
ase(await _.effect(x => x + 1)(1), 1)
|
|
622
|
-
assert.rejects(
|
|
623
|
-
async () => await _.effect(() => { throw new Error('hey') })(1),
|
|
624
|
-
new Error('hey'),
|
|
625
|
-
)
|
|
626
|
-
})
|
|
627
|
-
})
|
|
628
|
-
|
|
629
|
-
describe('_.effect.sync', () => {
|
|
630
|
-
aname(_.effect.sync, 'effect')
|
|
631
|
-
aname(_.effect.sync(hey), 'effect(hey)')
|
|
632
|
-
it('executes fn and returns first argument', async () => {
|
|
633
|
-
ase(_.effect.sync(x => x + 1)(1), 1)
|
|
634
|
-
assert.rejects(
|
|
635
|
-
async () => await _.effect(() => { throw new Error('hey') })(1),
|
|
636
|
-
new Error('hey'),
|
|
637
|
-
)
|
|
638
|
-
})
|
|
639
|
-
})
|
|
640
|
-
|
|
641
|
-
describe('_.tryCatch, _.tryCatch.sync', () => {
|
|
642
|
-
aname(_.tryCatch, 'tryCatch')
|
|
643
|
-
aname(_.tryCatch(add1, _.throw), 'tryCatch(add1, throw)')
|
|
644
|
-
it('tries a fn and catches with the other fn', async () => {
|
|
645
|
-
ase(await _.tryCatch(
|
|
646
|
-
x => x + 1,
|
|
647
|
-
() => 10,
|
|
648
|
-
)(1), 2)
|
|
649
|
-
ase(await _.tryCatch(
|
|
650
|
-
() => { throw new Error() },
|
|
651
|
-
() => 10,
|
|
652
|
-
)(1), 10)
|
|
653
|
-
ase(_.tryCatch.sync(
|
|
654
|
-
x => x + 1,
|
|
655
|
-
() => 10,
|
|
656
|
-
)(1), 2)
|
|
657
|
-
ase(_.tryCatch.sync(
|
|
658
|
-
() => { throw new Error() },
|
|
659
|
-
() => 10,
|
|
660
|
-
)(1), 10)
|
|
661
|
-
})
|
|
662
|
-
it('throws TypeError', async () => {
|
|
663
|
-
assert.throws(
|
|
664
|
-
() => _.tryCatch(1, _.noop),
|
|
665
|
-
new TypeError('try fn not a fn'),
|
|
666
|
-
)
|
|
667
|
-
assert.throws(
|
|
668
|
-
() => _.tryCatch(_.id, 0),
|
|
669
|
-
new TypeError('catch fn not a fn'),
|
|
670
|
-
)
|
|
671
|
-
})
|
|
672
|
-
})
|
|
673
|
-
|
|
674
|
-
describe('_.tryCatch.sync', () => {
|
|
675
|
-
aname(_.tryCatch.sync, 'tryCatch')
|
|
676
|
-
aname(_.tryCatch.sync(add1, _.throw), 'tryCatch(add1, throw)')
|
|
677
|
-
it('tries a sync fn and catches with the other fn', async () => {
|
|
678
|
-
ase(_.tryCatch.sync(
|
|
679
|
-
x => x + 1,
|
|
680
|
-
() => 10,
|
|
681
|
-
)(1), 2)
|
|
682
|
-
ase(_.tryCatch.sync(
|
|
683
|
-
() => { throw new Error() },
|
|
684
|
-
() => 10,
|
|
685
|
-
)(1), 10)
|
|
686
|
-
})
|
|
687
|
-
it('throws TypeError', async () => {
|
|
688
|
-
assert.throws(
|
|
689
|
-
() => _.tryCatch.sync(1, _.noop),
|
|
690
|
-
new TypeError('try fn not a fn'),
|
|
691
|
-
)
|
|
692
|
-
assert.throws(
|
|
693
|
-
() => _.tryCatch.sync(_.id, 0),
|
|
694
|
-
new TypeError('catch fn not a fn'),
|
|
695
|
-
)
|
|
696
|
-
})
|
|
697
|
-
})
|
|
698
|
-
|
|
699
|
-
describe('_.map', () => {
|
|
700
|
-
aname(_.map, 'map')
|
|
701
|
-
aname(_.map(add), 'map(add)')
|
|
702
|
-
it('async a -> b', async () => {
|
|
703
|
-
ade(
|
|
704
|
-
await _.map(delayedAdd1)([1, 2, 3]),
|
|
705
|
-
[2, 3, 4],
|
|
706
|
-
)
|
|
707
|
-
ade(
|
|
708
|
-
await _.map(delayedAdd1)(new Set([1,2,3])),
|
|
709
|
-
new Set([2, 3, 4]),
|
|
710
|
-
)
|
|
711
|
-
ade(
|
|
712
|
-
await _.map(delayedAdd1)(
|
|
713
|
-
new Map([['a', 1], ['b', 2], ['c', 3]])
|
|
714
|
-
),
|
|
715
|
-
new Map([['a', 2], ['b', 3], ['c', 4]]),
|
|
716
|
-
)
|
|
717
|
-
ade(
|
|
718
|
-
await _.map(delayedAdd1)(
|
|
719
|
-
{ a: 1, b: 2, c: 3 }
|
|
720
|
-
),
|
|
721
|
-
{ a: 2, b: 3, c: 4 },
|
|
722
|
-
)
|
|
723
|
-
}).timeout(5000)
|
|
724
|
-
it('calls fn with an implicit index', async () => {
|
|
725
|
-
ade(
|
|
726
|
-
await _.map((x, i) => ({ x, i }))([1, 2, 3]),
|
|
727
|
-
[{ x: 1, i: 0 }, { x: 2, i: 1 }, { x: 3, i: 2 }],
|
|
728
|
-
)
|
|
729
|
-
})
|
|
730
|
-
it('throws TypeError', async () => {
|
|
731
|
-
assert.rejects(
|
|
732
|
-
() => _.map(x => x)(1),
|
|
733
|
-
new TypeError('cannot map 1'),
|
|
734
|
-
)
|
|
735
|
-
assert.rejects(
|
|
736
|
-
() => _.map(x => x)(undefined),
|
|
737
|
-
new TypeError('cannot map undefined'),
|
|
738
|
-
)
|
|
739
|
-
assert.rejects(
|
|
740
|
-
() => _.map(x => x)(null),
|
|
741
|
-
new TypeError('cannot map null'),
|
|
742
|
-
)
|
|
743
|
-
})
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
describe('_.map.sync', () => {
|
|
747
|
-
aname(_.map.sync, 'map')
|
|
748
|
-
aname(_.map.sync(add), 'map(add)')
|
|
749
|
-
it('a -> b', async () => {
|
|
750
|
-
ade(
|
|
751
|
-
_.map.sync(add1)([1, 2, 3]),
|
|
752
|
-
[2, 3, 4],
|
|
753
|
-
)
|
|
754
|
-
ade(
|
|
755
|
-
_.map.sync(add1)(new Set([1,2,3])),
|
|
756
|
-
new Set([2, 3, 4]),
|
|
757
|
-
)
|
|
758
|
-
ade(
|
|
759
|
-
_.map.sync(add1)(
|
|
760
|
-
new Map([['a', 1], ['b', 2], ['c', 3]])
|
|
761
|
-
),
|
|
762
|
-
new Map([['a', 2], ['b', 3], ['c', 4]]),
|
|
763
|
-
)
|
|
764
|
-
ade(
|
|
765
|
-
_.map.sync(add1)(
|
|
766
|
-
{ a: 1, b: 2, c: 3 }
|
|
767
|
-
),
|
|
768
|
-
{ a: 2, b: 3, c: 4 },
|
|
769
|
-
)
|
|
770
|
-
}).timeout(5000)
|
|
771
|
-
it('calls fn with an implicit index', async () => {
|
|
772
|
-
ade(
|
|
773
|
-
_.map.sync((x, i) => ({ x, i }))([1, 2, 3]),
|
|
774
|
-
[{ x: 1, i: 0 }, { x: 2, i: 1 }, { x: 3, i: 2 }],
|
|
775
|
-
)
|
|
776
|
-
})
|
|
777
|
-
it('throws TypeError', async () => {
|
|
778
|
-
assert.throws(
|
|
779
|
-
() => _.map.sync(x => x)(1),
|
|
780
|
-
new TypeError('cannot map 1'),
|
|
781
|
-
)
|
|
782
|
-
assert.throws(
|
|
783
|
-
() => _.map.sync(x => x)(undefined),
|
|
784
|
-
new TypeError('cannot map undefined'),
|
|
785
|
-
)
|
|
786
|
-
assert.throws(
|
|
787
|
-
() => _.map.sync(x => x)(null),
|
|
788
|
-
new TypeError('cannot map null'),
|
|
789
|
-
)
|
|
790
|
-
})
|
|
791
|
-
})
|
|
792
|
-
|
|
793
|
-
describe('_.diverge', () => {
|
|
794
|
-
aname(_.diverge, 'diverge')
|
|
795
|
-
aname(_.diverge([hi, ho, hey]), 'diverge([...]{3})')
|
|
796
|
-
aname(_.diverge(new Set([hi, ho, hey])), 'diverge(Set{...}{3})')
|
|
797
|
-
aname(_.diverge(new Map(Object.entries({ a: hi, b: ho, c: hey }))), 'diverge(Map{...}{3})')
|
|
798
|
-
aname(_.diverge({ a: hi, b: ho, c: hey }), 'diverge({...}{3})')
|
|
799
|
-
it('diverges flow to provided container', async () => {
|
|
800
|
-
ade(
|
|
801
|
-
await _.diverge([hi, ho, hey])('yo'),
|
|
802
|
-
['yohi', 'yoho', 'yohey'],
|
|
803
|
-
)
|
|
804
|
-
ade(
|
|
805
|
-
await _.diverge(new Set([hi, ho, hey]))('yo'),
|
|
806
|
-
new Set(['yohi', 'yoho', 'yohey']),
|
|
807
|
-
)
|
|
808
|
-
ade(
|
|
809
|
-
await _.diverge(new Map([['a', hi], ['b', ho], ['c', hey]]))('yo'),
|
|
810
|
-
new Map([['a', 'yohi'], ['b', 'yoho'], ['c', 'yohey']])
|
|
811
|
-
)
|
|
812
|
-
ade(
|
|
813
|
-
await _.diverge({ a: hi, b: ho, c: hey })('yo'),
|
|
814
|
-
({ a: 'yohi', b: 'yoho', c: 'yohey' }),
|
|
815
|
-
)
|
|
816
|
-
})
|
|
817
|
-
it('throws TypeError', async () => {
|
|
818
|
-
assert.throws(
|
|
819
|
-
() => _.diverge('ayelmao'),
|
|
820
|
-
new TypeError('cannot diverge ayelmao'),
|
|
821
|
-
)
|
|
822
|
-
})
|
|
823
|
-
})
|
|
824
|
-
|
|
825
|
-
describe('_.diverge.sync', () => {
|
|
826
|
-
aname(_.diverge.sync, 'diverge')
|
|
827
|
-
aname(_.diverge.sync([hi, ho, hey]), 'diverge([...]{3})')
|
|
828
|
-
aname(_.diverge.sync(new Set([hi, ho, hey])), 'diverge(Set{...}{3})')
|
|
829
|
-
aname(_.diverge.sync(new Map(Object.entries({ a: hi, b: ho, c: hey }))), 'diverge(Map{...}{3})')
|
|
830
|
-
aname(_.diverge.sync({ a: hi, b: ho, c: hey }), 'diverge({...}{3})')
|
|
831
|
-
it('diverges flow to provided container', async () => {
|
|
832
|
-
ade(
|
|
833
|
-
_.diverge.sync([hi, hi, hi])('yo'),
|
|
834
|
-
['yohi', 'yohi', 'yohi'],
|
|
835
|
-
)
|
|
836
|
-
ade(
|
|
837
|
-
_.diverge.sync(new Set([hi, hi, hi]))('yo'),
|
|
838
|
-
new Set(['yohi', 'yohi', 'yohi']),
|
|
839
|
-
)
|
|
840
|
-
ade(
|
|
841
|
-
_.diverge.sync(new Map([['a', hi], ['b', hi], ['c', hi]]))('yo'),
|
|
842
|
-
new Map([['a', 'yohi'], ['b', 'yohi'], ['c', 'yohi']])
|
|
843
|
-
)
|
|
844
|
-
ade(
|
|
845
|
-
_.diverge.sync({ a: hi, b: hi, c: hi })('yo'),
|
|
846
|
-
({ a: 'yohi', b: 'yohi', c: 'yohi' }),
|
|
847
|
-
)
|
|
848
|
-
})
|
|
849
|
-
it('throws a TypeError', async () => {
|
|
850
|
-
assert.throws(
|
|
851
|
-
() => _.diverge.sync('ayelmao'),
|
|
852
|
-
new TypeError('cannot diverge ayelmao'),
|
|
853
|
-
)
|
|
854
|
-
})
|
|
855
|
-
})
|
|
856
|
-
|
|
857
|
-
describe('_.serialMap', () => {
|
|
858
|
-
aname(_.serialMap, 'serialMap')
|
|
859
|
-
aname(_.serialMap(delayedAdd1), 'serialMap(delayedAdd1)')
|
|
860
|
-
it('async a -> b in sequence', async () => {
|
|
861
|
-
ade(
|
|
862
|
-
await _.serialMap(delayedAdd1)([1, 2, 3]),
|
|
863
|
-
[2, 3, 4],
|
|
864
|
-
)
|
|
865
|
-
ade(
|
|
866
|
-
await _.serialMap(delayedAdd1)(new Set([1,2,3])),
|
|
867
|
-
new Set([2, 3, 4]),
|
|
868
|
-
)
|
|
869
|
-
ade(
|
|
870
|
-
await _.serialMap(delayedAdd1)(
|
|
871
|
-
new Map([['a', 1], ['b', 2], ['c', 3]])
|
|
872
|
-
),
|
|
873
|
-
new Map([['a', 2], ['b', 3], ['c', 4]]),
|
|
874
|
-
)
|
|
875
|
-
ade(
|
|
876
|
-
await _.serialMap(delayedAdd1)(
|
|
877
|
-
{ a: 1, b: 2, c: 3 }
|
|
878
|
-
),
|
|
879
|
-
{ a: 2, b: 3, c: 4 },
|
|
880
|
-
)
|
|
881
|
-
}).timeout(5000)
|
|
882
|
-
it('throws TypeError', async () => {
|
|
883
|
-
assert.rejects(
|
|
884
|
-
() => _.serialMap(x => x)(1),
|
|
885
|
-
new TypeError('cannot serialMap 1'),
|
|
886
|
-
)
|
|
887
|
-
assert.rejects(
|
|
888
|
-
() => _.serialMap(x => x)(undefined),
|
|
889
|
-
new TypeError('cannot serialMap undefined'),
|
|
890
|
-
)
|
|
891
|
-
assert.rejects(
|
|
892
|
-
() => _.serialMap(x => x)(null),
|
|
893
|
-
new TypeError('cannot serialMap null'),
|
|
894
|
-
)
|
|
895
|
-
})
|
|
896
|
-
})
|
|
897
|
-
|
|
898
|
-
describe('_.entryMap', () => {
|
|
899
|
-
aname(_.entryMap, 'entryMap')
|
|
900
|
-
aname(_.entryMap(delayedAdd1), 'entryMap(delayedAdd1)')
|
|
901
|
-
it('async a -> b entries', async () => {
|
|
902
|
-
ade(
|
|
903
|
-
await _.entryMap(delayedAdd1)([1, 2, 3]),
|
|
904
|
-
[2, 3, 4],
|
|
905
|
-
)
|
|
906
|
-
ade(
|
|
907
|
-
await _.entryMap(delayedAdd1)(new Set([1,2,3])),
|
|
908
|
-
new Set([2, 3, 4]),
|
|
909
|
-
)
|
|
910
|
-
ade(
|
|
911
|
-
await _.entryMap(async ([k, v]) => [k, await delayedAdd1(v)])(
|
|
912
|
-
new Map([['a', 1], ['b', 2], ['c', 3]])
|
|
913
|
-
),
|
|
914
|
-
new Map([['a', 2], ['b', 3], ['c', 4]]),
|
|
915
|
-
)
|
|
916
|
-
ade(
|
|
917
|
-
await _.entryMap(async ([k, v]) => [k, await delayedAdd1(v)])(
|
|
918
|
-
{ a: 1, b: 2, c: 3 }
|
|
919
|
-
),
|
|
920
|
-
{ a: 2, b: 3, c: 4 },
|
|
921
|
-
)
|
|
922
|
-
}).timeout(5000)
|
|
923
|
-
it('throws TypeError', async () => {
|
|
924
|
-
assert.rejects(
|
|
925
|
-
() => _.entryMap(x => x)(1),
|
|
926
|
-
new TypeError('cannot entryMap 1'),
|
|
927
|
-
)
|
|
928
|
-
assert.rejects(
|
|
929
|
-
() => _.entryMap(x => x)(undefined),
|
|
930
|
-
new TypeError('cannot entryMap undefined'),
|
|
931
|
-
)
|
|
932
|
-
assert.rejects(
|
|
933
|
-
() => _.entryMap(x => x)(null),
|
|
934
|
-
new TypeError('cannot entryMap null'),
|
|
935
|
-
)
|
|
936
|
-
})
|
|
937
|
-
})
|
|
938
|
-
|
|
939
|
-
describe('_.entryMap.sync', () => {
|
|
940
|
-
aname(_.entryMap, 'entryMap')
|
|
941
|
-
aname(_.entryMap(delayedAdd1), 'entryMap(delayedAdd1)')
|
|
942
|
-
it('a -> b entries', async () => {
|
|
943
|
-
ade(
|
|
944
|
-
_.entryMap.sync(add1)([1, 2, 3]),
|
|
945
|
-
[2, 3, 4],
|
|
946
|
-
)
|
|
947
|
-
ade(
|
|
948
|
-
_.entryMap.sync(add1)(new Set([1,2,3])),
|
|
949
|
-
new Set([2, 3, 4]),
|
|
950
|
-
)
|
|
951
|
-
ade(
|
|
952
|
-
_.entryMap.sync(([k, v]) => [k, add1(v)])(
|
|
953
|
-
new Map([['a', 1], ['b', 2], ['c', 3]])
|
|
954
|
-
),
|
|
955
|
-
new Map([['a', 2], ['b', 3], ['c', 4]]),
|
|
956
|
-
)
|
|
957
|
-
ade(
|
|
958
|
-
_.entryMap.sync(([k, v]) => [`${k}${k}`, add1(v)])(
|
|
959
|
-
{ a: 1, b: 2, c: 3 }
|
|
960
|
-
),
|
|
961
|
-
{ aa: 2, bb: 3, cc: 4 },
|
|
962
|
-
)
|
|
963
|
-
}).timeout(5000)
|
|
964
|
-
it('throws TypeError', async () => {
|
|
965
|
-
assert.throws(
|
|
966
|
-
() => _.entryMap.sync(x => x)(1),
|
|
967
|
-
new TypeError('cannot entryMap 1'),
|
|
968
|
-
)
|
|
969
|
-
assert.throws(
|
|
970
|
-
() => _.entryMap.sync(x => x)(undefined),
|
|
971
|
-
new TypeError('cannot entryMap undefined'),
|
|
972
|
-
)
|
|
973
|
-
assert.throws(
|
|
974
|
-
() => _.entryMap.sync(x => x)(null),
|
|
975
|
-
new TypeError('cannot entryMap null'),
|
|
976
|
-
)
|
|
977
|
-
})
|
|
978
|
-
})
|
|
979
|
-
|
|
980
|
-
describe('_.filter', () => {
|
|
981
|
-
aname(_.filter, 'filter')
|
|
982
|
-
aname(_.filter(isEven), 'filter(isEven)')
|
|
983
|
-
it('filters x by fn', async () => {
|
|
984
|
-
ade(
|
|
985
|
-
await _.filter(x => x === 1)([1,2,3]),
|
|
986
|
-
[1],
|
|
987
|
-
)
|
|
988
|
-
ade(
|
|
989
|
-
await _.filter(x => x === 1)(new Set([1,2,3])),
|
|
990
|
-
new Set([1]),
|
|
991
|
-
)
|
|
992
|
-
ade(
|
|
993
|
-
await _.filter(x => x === 1)(new Map([['a', 1],['b', 2]])),
|
|
994
|
-
new Map([['a', 1]]),
|
|
995
|
-
)
|
|
996
|
-
ade(
|
|
997
|
-
await _.filter(x => x === 1)({ a: 1, b: 2 }),
|
|
998
|
-
({ a: 1 }),
|
|
999
|
-
)
|
|
1000
|
-
})
|
|
1001
|
-
it('throws TypeError', async () => {
|
|
1002
|
-
assert.rejects(
|
|
1003
|
-
() => _.filter(x => x)(1),
|
|
1004
|
-
new TypeError('cannot filter 1'),
|
|
1005
|
-
)
|
|
1006
|
-
assert.rejects(
|
|
1007
|
-
() => _.filter(x => x)(undefined),
|
|
1008
|
-
new TypeError('cannot filter undefined'),
|
|
1009
|
-
)
|
|
1010
|
-
assert.rejects(
|
|
1011
|
-
() => _.filter(x => x)(null),
|
|
1012
|
-
new TypeError('cannot filter null'),
|
|
1013
|
-
)
|
|
1014
|
-
})
|
|
1015
|
-
})
|
|
1016
|
-
|
|
1017
|
-
describe('_.filter.sync', () => {
|
|
1018
|
-
aname(_.filter.sync, 'filter')
|
|
1019
|
-
aname(_.filter.sync(isEven), 'filter(isEven)')
|
|
1020
|
-
it('filters x by fn', async () => {
|
|
1021
|
-
ade(
|
|
1022
|
-
_.filter.sync(x => x === 1)([1,2,3]),
|
|
1023
|
-
[1],
|
|
1024
|
-
)
|
|
1025
|
-
ade(
|
|
1026
|
-
_.filter.sync(x => x === 1)(new Set([1,2,3])),
|
|
1027
|
-
new Set([1]),
|
|
1028
|
-
)
|
|
1029
|
-
ade(
|
|
1030
|
-
_.filter.sync(x => x === 1)(new Map([['a', 1],['b', 2]])),
|
|
1031
|
-
new Map([['a', 1]]),
|
|
1032
|
-
)
|
|
1033
|
-
ade(
|
|
1034
|
-
_.filter.sync(x => x === 1)({ a: 1, b: 2 }),
|
|
1035
|
-
({ a: 1 }),
|
|
1036
|
-
)
|
|
1037
|
-
})
|
|
1038
|
-
it('throws TypeError', async () => {
|
|
1039
|
-
assert.throws(
|
|
1040
|
-
() => _.filter.sync(x => x)(1),
|
|
1041
|
-
new TypeError('cannot filter 1'),
|
|
1042
|
-
)
|
|
1043
|
-
assert.throws(
|
|
1044
|
-
() => _.filter.sync(x => x)(undefined),
|
|
1045
|
-
new TypeError('cannot filter undefined'),
|
|
1046
|
-
)
|
|
1047
|
-
assert.throws(
|
|
1048
|
-
() => _.filter.sync(x => x)(null),
|
|
1049
|
-
new TypeError('cannot filter null'),
|
|
1050
|
-
)
|
|
1051
|
-
})
|
|
1052
|
-
})
|
|
1053
|
-
|
|
1054
|
-
describe('_.reduce', () => {
|
|
1055
|
-
aname(_.reduce, 'reduce')
|
|
1056
|
-
aname(_.reduce(add), 'reduce(add)')
|
|
1057
|
-
aname(_.reduce(add, 10), 'reduce(add, 10)')
|
|
1058
|
-
it('can add 1 2 3', async () => {
|
|
1059
|
-
ase(await _.reduce(add)([1, 2, 3]), 6)
|
|
1060
|
-
ase(await _.reduce(add)(new Set([1, 2, 3])), 6)
|
|
1061
|
-
ase(await _.reduce(add)(new Map([[1, 1], [2, 2], [3, 3]])), 6)
|
|
1062
|
-
ase(await _.reduce(add)({ a: 1, b: 2, c: 3 }), 6)
|
|
1063
|
-
})
|
|
1064
|
-
it('can add 1 2 3 starting with 10', async () => {
|
|
1065
|
-
ase(await _.reduce(add, 10)([1, 2, 3]), 6 + 10)
|
|
1066
|
-
ase(await _.reduce(add, 10)(new Set([1, 2, 3])), 6 + 10)
|
|
1067
|
-
ase(await _.reduce(add, 10)(new Map([[1, 1], [2, 2], [3, 3]])), 6 + 10)
|
|
1068
|
-
ase(await _.reduce(add, 10)({ a: 1, b: 2, c: 3 }), 6 + 10)
|
|
1069
|
-
})
|
|
1070
|
-
it('=> first element for array length 1', async () => {
|
|
1071
|
-
ase(await _.reduce(add)([1]), 1)
|
|
1072
|
-
ase(await _.reduce(add)(new Set([1])), 1)
|
|
1073
|
-
ase(await _.reduce(add)(new Map([[1, 1]])), 1)
|
|
1074
|
-
ase(await _.reduce(add)({ a: 1 }), 1)
|
|
1075
|
-
})
|
|
1076
|
-
it('=> memo for []', async () => {
|
|
1077
|
-
ase(await _.reduce(add, 'yoyoyo')([]), 'yoyoyo')
|
|
1078
|
-
ase(await _.reduce(add, 'yoyoyo')(new Set([])), 'yoyoyo')
|
|
1079
|
-
ase(await _.reduce(add, 'yoyoyo')(new Map([])), 'yoyoyo')
|
|
1080
|
-
ase(await _.reduce(add, 'yoyoyo')({}), 'yoyoyo')
|
|
1081
|
-
})
|
|
1082
|
-
it('=> undefined for []', async () => {
|
|
1083
|
-
ase(await _.reduce(add)([]), undefined)
|
|
1084
|
-
ase(await _.reduce(add)(new Set([])), undefined)
|
|
1085
|
-
ase(await _.reduce(add)(new Map([])), undefined)
|
|
1086
|
-
ase(await _.reduce(add)({}), undefined)
|
|
1087
|
-
})
|
|
1088
|
-
it('many calls', async () => {
|
|
1089
|
-
ase(await _.reduce(add)(range(0, 10000)), 49995000)
|
|
1090
|
-
})
|
|
1091
|
-
it('throws TypeError', async () => {
|
|
1092
|
-
assert.rejects(
|
|
1093
|
-
() => _.reduce(x => x)(1),
|
|
1094
|
-
new TypeError('cannot reduce 1'),
|
|
1095
|
-
)
|
|
1096
|
-
assert.rejects(
|
|
1097
|
-
() => _.reduce(x => x)(undefined),
|
|
1098
|
-
new TypeError('cannot reduce undefined'),
|
|
1099
|
-
)
|
|
1100
|
-
assert.rejects(
|
|
1101
|
-
() => _.reduce(x => x)(null),
|
|
1102
|
-
new TypeError('cannot reduce null'),
|
|
1103
|
-
)
|
|
1104
|
-
})
|
|
1105
|
-
})
|
|
1106
|
-
|
|
1107
|
-
describe('_.reduce.sync', () => {
|
|
1108
|
-
aname(_.reduce.sync, 'reduce')
|
|
1109
|
-
aname(_.reduce.sync(add), 'reduce(add)')
|
|
1110
|
-
aname(_.reduce.sync(add, 10), 'reduce(add, 10)')
|
|
1111
|
-
it('can add 1 2 3', async () => {
|
|
1112
|
-
ase(_.reduce.sync(add)([1, 2, 3]), 6)
|
|
1113
|
-
ase(_.reduce.sync(add)(new Set([1, 2, 3])), 6)
|
|
1114
|
-
ase(_.reduce.sync(add)(new Map([[1, 1], [2, 2], [3, 3]])), 6)
|
|
1115
|
-
ase(_.reduce.sync(add)({ a: 1, b: 2, c: 3 }), 6)
|
|
1116
|
-
})
|
|
1117
|
-
it('can add 1 2 3 starting with 10', async () => {
|
|
1118
|
-
ase(_.reduce.sync(add, 10)([1, 2, 3]), 6 + 10)
|
|
1119
|
-
ase(_.reduce.sync(add, 10)(new Set([1, 2, 3])), 6 + 10)
|
|
1120
|
-
ase(_.reduce.sync(add, 10)(new Map([[1, 1], [2, 2], [3, 3]])), 6 + 10)
|
|
1121
|
-
ase(_.reduce.sync(add, 10)({ a: 1, b: 2, c: 3 }), 6 + 10)
|
|
1122
|
-
})
|
|
1123
|
-
it('throws TypeError', async () => {
|
|
1124
|
-
assert.throws(
|
|
1125
|
-
() => _.reduce.sync(x => x)(1),
|
|
1126
|
-
new TypeError('cannot reduce 1'),
|
|
1127
|
-
)
|
|
1128
|
-
assert.throws(
|
|
1129
|
-
() => _.reduce.sync(x => x)(undefined),
|
|
1130
|
-
new TypeError('cannot reduce undefined'),
|
|
1131
|
-
)
|
|
1132
|
-
assert.throws(
|
|
1133
|
-
() => _.reduce.sync(x => x)(null),
|
|
1134
|
-
new TypeError('cannot reduce null'),
|
|
1135
|
-
)
|
|
1136
|
-
})
|
|
1137
|
-
})
|
|
1138
|
-
|
|
1139
|
-
describe('_.not', () => {
|
|
1140
|
-
aname(_.not, 'not')
|
|
1141
|
-
aname(_.not(_.exists), 'not(exists)')
|
|
1142
|
-
aname(_.not('hey'), 'not(() => \'hey\')')
|
|
1143
|
-
it('x => !x', async () => {
|
|
1144
|
-
ase(await _.not(_.id)(true), false)
|
|
1145
|
-
ase(await _.not(_.get('a'))({ a: false }), true)
|
|
1146
|
-
ase(await _.not(true)(Infinity), false)
|
|
1147
|
-
})
|
|
1148
|
-
})
|
|
1149
|
-
|
|
1150
|
-
describe('_.not.sync', () => {
|
|
1151
|
-
aname(_.not.sync, 'not')
|
|
1152
|
-
aname(_.not.sync(_.exists), 'not(exists)')
|
|
1153
|
-
aname(_.not.sync('hey'), 'not(() => \'hey\')')
|
|
1154
|
-
it('x => !x', async () => {
|
|
1155
|
-
ase(_.not.sync(_.id)(true), false)
|
|
1156
|
-
ase(_.not.sync(_.get('a'))({ a: false }), true)
|
|
1157
|
-
ase(_.not.sync(true)(Infinity), false)
|
|
1158
|
-
})
|
|
1159
|
-
})
|
|
1160
|
-
|
|
1161
|
-
describe('_.any', () => {
|
|
1162
|
-
aname(_.any, 'any')
|
|
1163
|
-
aname(_.any(hi), 'any(hi)')
|
|
1164
|
-
it('tests if any elements in arr pass fn', async () => {
|
|
1165
|
-
ase(await _.any(x => x === 1)([1, 2, 3]), true)
|
|
1166
|
-
ase(await _.any(x => x === 1)([3, 3, 3]), false)
|
|
1167
|
-
ase(await _.any(true, () => false)([3, 3, 3]), true)
|
|
1168
|
-
ase(await _.any(false, () => 0)([3, 3, 3]), false)
|
|
1169
|
-
})
|
|
1170
|
-
})
|
|
1171
|
-
|
|
1172
|
-
describe('_.any.sync', () => {
|
|
1173
|
-
aname(_.any.sync, 'any')
|
|
1174
|
-
aname(_.any.sync(hi), 'any(hi)')
|
|
1175
|
-
it('tests if any elements in arr pass fn', async () => {
|
|
1176
|
-
ase(_.any.sync(x => x === 1)([1, 2, 3]), true)
|
|
1177
|
-
ase(_.any.sync(x => x === 1)([3, 3, 3]), false)
|
|
1178
|
-
ase(_.any.sync(true, () => false)([3, 3, 3]), true)
|
|
1179
|
-
ase(_.any.sync(false, () => 0)([3, 3, 3]), false)
|
|
1180
|
-
})
|
|
1181
|
-
})
|
|
1182
|
-
|
|
1183
|
-
describe('_.every', () => {
|
|
1184
|
-
aname(_.every, 'every')
|
|
1185
|
-
aname(_.every(_.exists), 'every(exists)')
|
|
1186
|
-
it('tests is every element in arr pass fn', async () => {
|
|
1187
|
-
ase(await _.every(x => x === 1)([1, 1, 1]), true)
|
|
1188
|
-
ase(await _.every(x => x === 1)([1, 2, 3]), false)
|
|
1189
|
-
ase(await _.every(true)([1, 2, 3]), true)
|
|
1190
|
-
ase(await _.every(false)([1, 2, 3]), false)
|
|
1191
|
-
})
|
|
1192
|
-
})
|
|
1193
|
-
|
|
1194
|
-
describe('_.every.sync', () => {
|
|
1195
|
-
aname(_.every.sync, 'every')
|
|
1196
|
-
aname(_.every.sync(_.exists), 'every(exists)')
|
|
1197
|
-
it('tests is every element in arr pass fn', async () => {
|
|
1198
|
-
ase(_.every.sync(x => x === 1)([1, 1, 1]), true)
|
|
1199
|
-
ase(_.every.sync(x => x === 1)([1, 2, 3]), false)
|
|
1200
|
-
ase(_.every.sync(true)([1, 2, 3]), true)
|
|
1201
|
-
ase(_.every.sync(false)([1, 2, 3]), false)
|
|
1202
|
-
})
|
|
1203
|
-
})
|
|
1204
|
-
|
|
1205
|
-
describe('_.and', () => {
|
|
1206
|
-
aname(_.and, 'and')
|
|
1207
|
-
aname(_.and(hi, ho), 'and(hi, ho)')
|
|
1208
|
-
it('=> true if x passes all fns', async () => {
|
|
1209
|
-
ase(await _.and(
|
|
1210
|
-
x => x.includes(1),
|
|
1211
|
-
x => x.includes(2),
|
|
1212
|
-
)([1, 2, 3]), true)
|
|
1213
|
-
ase(await _.and(
|
|
1214
|
-
x => x.includes(1),
|
|
1215
|
-
x => x.includes(2),
|
|
1216
|
-
)([1, 3, 3]), false)
|
|
1217
|
-
ase(await _.and(true, () => true)([1, 3, 3]), true)
|
|
1218
|
-
ase(await _.and(false, () => true)([1, 3, 3]), false)
|
|
1219
|
-
})
|
|
1220
|
-
})
|
|
1221
|
-
|
|
1222
|
-
describe('_.and.sync', () => {
|
|
1223
|
-
aname(_.and.sync, 'and')
|
|
1224
|
-
aname(_.and.sync(hi, ho), 'and(hi, ho)')
|
|
1225
|
-
it('=> true if x passes all fns', async () => {
|
|
1226
|
-
ase(_.and.sync(
|
|
1227
|
-
x => x.includes(1),
|
|
1228
|
-
x => x.includes(2),
|
|
1229
|
-
)([1, 2, 3]), true)
|
|
1230
|
-
ase(_.and.sync(
|
|
1231
|
-
x => x.includes(1),
|
|
1232
|
-
x => x.includes(2),
|
|
1233
|
-
)([1, 3, 3]), false)
|
|
1234
|
-
ase(_.and.sync(true, () => true)([1, 3, 3]), true)
|
|
1235
|
-
ase(_.and.sync(false, () => true)([1, 3, 3]), false)
|
|
1236
|
-
})
|
|
1237
|
-
})
|
|
1238
|
-
|
|
1239
|
-
describe('_.or', () => {
|
|
1240
|
-
aname(_.or, 'or')
|
|
1241
|
-
aname(_.or(hi, ho), 'or(hi, ho)')
|
|
1242
|
-
it('=> true if x passes any fns', async () => {
|
|
1243
|
-
ase(await _.or(
|
|
1244
|
-
x => x.includes(1),
|
|
1245
|
-
x => x.includes(2),
|
|
1246
|
-
)([1, 1, 1]), true)
|
|
1247
|
-
ase(await _.or(
|
|
1248
|
-
x => x.includes(1),
|
|
1249
|
-
x => x.includes(2),
|
|
1250
|
-
)([3, 3, 3]), false)
|
|
1251
|
-
ase(await _.or(true, () => false)([3, 3, 3]), true)
|
|
1252
|
-
ase(await _.or(false, () => false)([3, 3, 3]), false)
|
|
1253
|
-
})
|
|
1254
|
-
})
|
|
1255
|
-
|
|
1256
|
-
describe('_.or.sync', () => {
|
|
1257
|
-
aname(_.or.sync, 'or')
|
|
1258
|
-
aname(_.or.sync(hi, ho), 'or(hi, ho)')
|
|
1259
|
-
it('=> true if x passes any fns', async () => {
|
|
1260
|
-
ase(_.or.sync(
|
|
1261
|
-
x => x.includes(1),
|
|
1262
|
-
x => x.includes(2),
|
|
1263
|
-
)([1, 1, 1]), true)
|
|
1264
|
-
ase(_.or.sync(
|
|
1265
|
-
x => x.includes(1),
|
|
1266
|
-
x => x.includes(2),
|
|
1267
|
-
)([3, 3, 3]), false)
|
|
1268
|
-
ase(_.or.sync(true, () => false)([3, 3, 3]), true)
|
|
1269
|
-
ase(_.or.sync(false, () => false)([3, 3, 3]), false)
|
|
1270
|
-
})
|
|
1271
|
-
})
|
|
1272
|
-
|
|
1273
|
-
describe('_.eq', () => {
|
|
1274
|
-
aname(_.eq, 'eq')
|
|
1275
|
-
aname(_.eq(_.id, _.id, _.noop), 'eq(id, id, noop)')
|
|
1276
|
-
it('=> true if all fns return ===', async () => {
|
|
1277
|
-
ase(await _.eq(
|
|
1278
|
-
x => x,
|
|
1279
|
-
async x => x + 1 - 1,
|
|
1280
|
-
async x => x * 1,
|
|
1281
|
-
)(1), true)
|
|
1282
|
-
ase(await _.eq(
|
|
1283
|
-
x => x,
|
|
1284
|
-
async x => x + 1 - 1,
|
|
1285
|
-
async x => x * 2,
|
|
1286
|
-
)(1), false)
|
|
1287
|
-
})
|
|
1288
|
-
it('works for values', async () => {
|
|
1289
|
-
ase(await _.eq(
|
|
1290
|
-
x => x,
|
|
1291
|
-
async x => x + 1 - 1,
|
|
1292
|
-
async x => x * 1,
|
|
1293
|
-
1,
|
|
1294
|
-
)(1), true)
|
|
1295
|
-
ase(await _.eq(
|
|
1296
|
-
x => x,
|
|
1297
|
-
0,
|
|
1298
|
-
)(1), false)
|
|
1299
|
-
})
|
|
1300
|
-
})
|
|
1301
|
-
|
|
1302
|
-
describe('_.eq.sync', () => {
|
|
1303
|
-
aname(_.eq.sync, 'eq')
|
|
1304
|
-
aname(_.eq.sync(_.id, _.id, _.noop), 'eq(id, id, noop)')
|
|
1305
|
-
it('=> true if all sync fns return ===', async () => {
|
|
1306
|
-
ase(_.eq.sync(
|
|
1307
|
-
x => x,
|
|
1308
|
-
x => x + 1 - 1,
|
|
1309
|
-
x => x * 1,
|
|
1310
|
-
)(1), true)
|
|
1311
|
-
ase(_.eq.sync(
|
|
1312
|
-
x => x,
|
|
1313
|
-
x => x + 1 - 1,
|
|
1314
|
-
x => x * 2,
|
|
1315
|
-
)(1), false)
|
|
1316
|
-
})
|
|
1317
|
-
it('works for values', async () => {
|
|
1318
|
-
ase(_.eq.sync(
|
|
1319
|
-
x => x,
|
|
1320
|
-
x => x + 1 - 1,
|
|
1321
|
-
x => x * 1,
|
|
1322
|
-
1,
|
|
1323
|
-
)(1), true)
|
|
1324
|
-
ase(_.eq.sync(
|
|
1325
|
-
x => x,
|
|
1326
|
-
0,
|
|
1327
|
-
)(1), false)
|
|
1328
|
-
})
|
|
1329
|
-
})
|
|
1330
|
-
|
|
1331
|
-
describe('_.lt', () => {
|
|
1332
|
-
aname(_.lt, 'lt')
|
|
1333
|
-
aname(_.lt(_.id, add1), 'lt(id, add1)')
|
|
1334
|
-
it('=> true if all lefts < rights', async () => {
|
|
1335
|
-
ase(await _.lt(
|
|
1336
|
-
x => x + 1,
|
|
1337
|
-
x => x + 2,
|
|
1338
|
-
)(1), true)
|
|
1339
|
-
ase(await _.lt(
|
|
1340
|
-
x => x + 2,
|
|
1341
|
-
x => x + 1,
|
|
1342
|
-
)(1), false)
|
|
1343
|
-
ase(await _.lt(
|
|
1344
|
-
x => x + 1,
|
|
1345
|
-
x => x + 1,
|
|
1346
|
-
)(1), false)
|
|
1347
|
-
ase(await _.lt(1, 2, 3)(Infinity), true)
|
|
1348
|
-
ase(await _.lt(3, 2, 1)(Infinity), false)
|
|
1349
|
-
})
|
|
1350
|
-
})
|
|
1351
|
-
|
|
1352
|
-
describe('_.lt.sync', () => {
|
|
1353
|
-
aname(_.lt.sync, 'lt')
|
|
1354
|
-
aname(_.lt.sync(_.id, add1), 'lt(id, add1)')
|
|
1355
|
-
it('=> true if all lefts < rights', async () => {
|
|
1356
|
-
ase(_.lt.sync(
|
|
1357
|
-
x => x + 1,
|
|
1358
|
-
x => x + 2,
|
|
1359
|
-
)(1), true)
|
|
1360
|
-
ase(_.lt.sync(
|
|
1361
|
-
x => x + 2,
|
|
1362
|
-
x => x + 1,
|
|
1363
|
-
)(1), false)
|
|
1364
|
-
ase(_.lt.sync(
|
|
1365
|
-
x => x + 1,
|
|
1366
|
-
x => x + 1,
|
|
1367
|
-
)(1), false)
|
|
1368
|
-
ase(_.lt.sync(1, 2, 3)(Infinity), true)
|
|
1369
|
-
ase(_.lt.sync(3, 2, 1)(Infinity), false)
|
|
1370
|
-
})
|
|
1371
|
-
})
|
|
1372
|
-
|
|
1373
|
-
describe('_.lte', () => {
|
|
1374
|
-
aname(_.lte, 'lte')
|
|
1375
|
-
aname(_.lte(_.id, add1), 'lte(id, add1)')
|
|
1376
|
-
it('=> true if all lefts <= rights', async () => {
|
|
1377
|
-
ase(await _.lte(
|
|
1378
|
-
x => x + 1,
|
|
1379
|
-
x => x + 2,
|
|
1380
|
-
)(1), true)
|
|
1381
|
-
ase(await _.lte(
|
|
1382
|
-
x => x + 2,
|
|
1383
|
-
x => x + 1,
|
|
1384
|
-
)(1), false)
|
|
1385
|
-
ase(await _.lte(
|
|
1386
|
-
x => x + 1,
|
|
1387
|
-
x => x + 1,
|
|
1388
|
-
)(1), true)
|
|
1389
|
-
ase(await _.lte(1, 2, 3)(Infinity), true)
|
|
1390
|
-
ase(await _.lte(3, 2, 1)(Infinity), false)
|
|
1391
|
-
})
|
|
1392
|
-
})
|
|
1393
|
-
|
|
1394
|
-
describe('_.lte.sync', () => {
|
|
1395
|
-
aname(_.lte.sync, 'lte')
|
|
1396
|
-
aname(_.lte.sync(_.id, add1), 'lte(id, add1)')
|
|
1397
|
-
it('=> true if all lefts <= rights', async () => {
|
|
1398
|
-
ase(_.lte.sync(
|
|
1399
|
-
x => x + 1,
|
|
1400
|
-
x => x + 2,
|
|
1401
|
-
)(1), true)
|
|
1402
|
-
ase(_.lte.sync(
|
|
1403
|
-
x => x + 2,
|
|
1404
|
-
x => x + 1,
|
|
1405
|
-
)(1), false)
|
|
1406
|
-
ase(_.lte.sync(
|
|
1407
|
-
x => x + 1,
|
|
1408
|
-
x => x + 1,
|
|
1409
|
-
)(1), true)
|
|
1410
|
-
ase(_.lte.sync(1, 2, 3)(Infinity), true)
|
|
1411
|
-
ase(_.lte.sync(3, 2, 1)(Infinity), false)
|
|
1412
|
-
})
|
|
1413
|
-
})
|
|
1414
|
-
|
|
1415
|
-
describe('_.gt', () => {
|
|
1416
|
-
aname(_.gt, 'gt')
|
|
1417
|
-
aname(_.gt(add1, _.id), 'gt(add1, id)')
|
|
1418
|
-
it('=> true if all lefts > rights', async () => {
|
|
1419
|
-
ase(await _.gt(
|
|
1420
|
-
x => x + 2,
|
|
1421
|
-
x => x + 1,
|
|
1422
|
-
)(1), true)
|
|
1423
|
-
ase(await _.gt(
|
|
1424
|
-
x => x + 1,
|
|
1425
|
-
x => x + 2,
|
|
1426
|
-
)(1), false)
|
|
1427
|
-
ase(await _.gt(
|
|
1428
|
-
x => x + 1,
|
|
1429
|
-
x => x + 1,
|
|
1430
|
-
)(1), false)
|
|
1431
|
-
ase(await _.gt(3, 2, 1)(Infinity), true)
|
|
1432
|
-
ase(await _.gt(1, 2, 3)(Infinity), false)
|
|
1433
|
-
})
|
|
1434
|
-
})
|
|
1435
|
-
|
|
1436
|
-
describe('_.gt.sync', () => {
|
|
1437
|
-
aname(_.gt.sync, 'gt')
|
|
1438
|
-
aname(_.gt.sync(add1, _.id), 'gt(add1, id)')
|
|
1439
|
-
it('=> true if all lefts > rights', async () => {
|
|
1440
|
-
ase(_.gt.sync(
|
|
1441
|
-
x => x + 2,
|
|
1442
|
-
x => x + 1,
|
|
1443
|
-
)(1), true)
|
|
1444
|
-
ase(_.gt.sync(
|
|
1445
|
-
x => x + 1,
|
|
1446
|
-
x => x + 2,
|
|
1447
|
-
)(1), false)
|
|
1448
|
-
ase(_.gt.sync(
|
|
1449
|
-
x => x + 1,
|
|
1450
|
-
x => x + 1,
|
|
1451
|
-
)(1), false)
|
|
1452
|
-
ase(_.gt.sync(3, 2, 1)(Infinity), true)
|
|
1453
|
-
ase(_.gt.sync(1, 2, 3)(Infinity), false)
|
|
1454
|
-
})
|
|
1455
|
-
})
|
|
1456
|
-
|
|
1457
|
-
describe('_.gte', () => {
|
|
1458
|
-
aname(_.gte, 'gte')
|
|
1459
|
-
aname(_.gte(_.id, _.id), 'gte(id, id)')
|
|
1460
|
-
it('=> true if all lefts >= rights', async () => {
|
|
1461
|
-
ase(await _.gte(
|
|
1462
|
-
x => x + 2,
|
|
1463
|
-
x => x + 1,
|
|
1464
|
-
)(1), true)
|
|
1465
|
-
ase(await _.gte(
|
|
1466
|
-
x => x + 1,
|
|
1467
|
-
x => x + 2,
|
|
1468
|
-
)(1), false)
|
|
1469
|
-
ase(await _.gte(
|
|
1470
|
-
x => x + 1,
|
|
1471
|
-
x => x + 1,
|
|
1472
|
-
)(1), true)
|
|
1473
|
-
ase(await _.gte(3, 2, 1)(Infinity), true)
|
|
1474
|
-
ase(await _.gte(1, 2, 3)(Infinity), false)
|
|
1475
|
-
})
|
|
1476
|
-
})
|
|
1477
|
-
|
|
1478
|
-
describe('_.gte.sync', () => {
|
|
1479
|
-
aname(_.gte.sync, 'gte')
|
|
1480
|
-
aname(_.gte.sync(_.id, _.id), 'gte(id, id)')
|
|
1481
|
-
it('=> true if all lefts >= rights', async () => {
|
|
1482
|
-
ase(_.gte.sync(
|
|
1483
|
-
x => x + 2,
|
|
1484
|
-
x => x + 1,
|
|
1485
|
-
)(1), true)
|
|
1486
|
-
ase(_.gte.sync(
|
|
1487
|
-
x => x + 1,
|
|
1488
|
-
x => x + 2,
|
|
1489
|
-
)(1), false)
|
|
1490
|
-
ase(_.gte.sync(
|
|
1491
|
-
x => x + 1,
|
|
1492
|
-
x => x + 1,
|
|
1493
|
-
)(1), true)
|
|
1494
|
-
ase(_.gte.sync(3, 2, 1)(Infinity), true)
|
|
1495
|
-
ase(_.gte.sync(1, 2, 3)(Infinity), false)
|
|
1496
|
-
})
|
|
1497
|
-
})
|
|
1498
|
-
|
|
1499
|
-
describe('_.get', () => {
|
|
1500
|
-
aname(_.get, 'get')
|
|
1501
|
-
aname(_.get('hey'), 'get(\'hey\')')
|
|
1502
|
-
aname(_.get(1), 'get(1)')
|
|
1503
|
-
aname(_.get([1, 'hey']), 'get([...]{2})')
|
|
1504
|
-
const x = { a: { b: { c: 1 } } }
|
|
1505
|
-
const y = [1, 2, [3, [4]]]
|
|
1506
|
-
it('safely gets a property', async () => {
|
|
1507
|
-
ase(_.get('a')({ a: 1 }), 1)
|
|
1508
|
-
ase(_.get('a')(new Map([['a', 1]])), 1)
|
|
1509
|
-
ase(_.get('b')({ a: 1 }), undefined)
|
|
1510
|
-
ase(_.get('b')({}), undefined)
|
|
1511
|
-
ase(_.get('b')(), undefined)
|
|
1512
|
-
ase(_.get('a.b.c')(x), 1)
|
|
1513
|
-
ase(_.get('a.b.d')(x), undefined)
|
|
1514
|
-
ase(_.get('a.b.d')({}), undefined)
|
|
1515
|
-
ase(_.get('a.b.d')(), undefined)
|
|
1516
|
-
ase(_.get(0)(y), 1)
|
|
1517
|
-
ade(_.get(2)(y), [3, [4]])
|
|
1518
|
-
ase(_.flow.sync(_.get(2), _.get(0))(y), 3)
|
|
1519
|
-
ase(_.get('2.0')(y), 3)
|
|
1520
|
-
ase(_.flow.sync(_.get(2), _.get(1), _.get(0))(y), 4)
|
|
1521
|
-
ase(_.get('2.1.0')(y), 4)
|
|
1522
|
-
ase(_.get(3)(y), undefined)
|
|
1523
|
-
ase(_.get('a')('hey'), undefined)
|
|
1524
|
-
ase(_.get('a')(1), undefined)
|
|
1525
|
-
})
|
|
1526
|
-
it('works with array keys', async () => {
|
|
1527
|
-
ase(_.get(['a'])({ a: 1 }), 1)
|
|
1528
|
-
ase(_.get(['a.b'])({ 'a.b': 1 }), 1)
|
|
1529
|
-
ase(_.get(['a', 'b', 'c'])(x), 1)
|
|
1530
|
-
ase(_.get(['a', 'b', 'd'])(x), undefined)
|
|
1531
|
-
ase(_.get('b', 'default')({}), 'default')
|
|
1532
|
-
})
|
|
1533
|
-
})
|
|
1534
|
-
|
|
1535
|
-
describe('_.lookup', () => {
|
|
1536
|
-
aname(_.lookup, 'lookup')
|
|
1537
|
-
aname(_.lookup([]), 'lookup([])')
|
|
1538
|
-
aname(_.lookup([1, 2, 3]), 'lookup([...]{3})')
|
|
1539
|
-
aname(_.lookup(new Set()), 'lookup(Set{})')
|
|
1540
|
-
aname(_.lookup(new Set([1, 2])), 'lookup(Set{...}{2})')
|
|
1541
|
-
aname(_.lookup(new Map()), 'lookup(Map{})')
|
|
1542
|
-
aname(_.lookup(new Map([['a', 1]])), 'lookup(Map{...}{1})')
|
|
1543
|
-
const x = { a: { b: { c: 1 } } }
|
|
1544
|
-
const y = [1, 2, [3, [4]]]
|
|
1545
|
-
it('like _.get but the store is the first argument', async () => {
|
|
1546
|
-
ase(_.lookup({ a: 1 })('a'), 1)
|
|
1547
|
-
ase(_.lookup(new Map([['a', 1]]))('a'), 1)
|
|
1548
|
-
ase(_.lookup({ a: 1 })('b'), undefined)
|
|
1549
|
-
ase(_.lookup({})('b'), undefined)
|
|
1550
|
-
ase(_.lookup()('b'), undefined)
|
|
1551
|
-
ase(_.lookup(x)('a.b.c'), 1)
|
|
1552
|
-
ase(_.lookup(x)('a.b.d'), undefined)
|
|
1553
|
-
ase(_.lookup({})('a.b.d'), undefined)
|
|
1554
|
-
ase(_.lookup()('a.b.d'), undefined)
|
|
1555
|
-
ase(_.lookup(y)(0), 1)
|
|
1556
|
-
ade(_.lookup(y)(2), [3, [4]])
|
|
1557
|
-
})
|
|
1558
|
-
})
|
|
1559
|
-
|
|
1560
|
-
describe('_.put', () => {
|
|
1561
|
-
aname(_.put, 'put')
|
|
1562
|
-
aname(_.put(['a', 1], ['b', 2]), 'put([a, () => 1], [b, () => 2])')
|
|
1563
|
-
it('puts a property on current payload, passing in payload', async () => {
|
|
1564
|
-
ade(
|
|
1565
|
-
await _.put(
|
|
1566
|
-
['hey', async x => x.ho + 1],
|
|
1567
|
-
['yo', async x => x.ho + 2],
|
|
1568
|
-
)({ ho: 1 }),
|
|
1569
|
-
({ hey: 2, ho: 1, yo: 3 }),
|
|
1570
|
-
)
|
|
1571
|
-
})
|
|
1572
|
-
})
|
|
1573
|
-
|
|
1574
|
-
// _.put({ a: 1 })
|
|
1575
|
-
// _.put({ a: 1, b: 2 })
|
|
1576
|
-
// TODO: change put api to this
|
|
1577
|
-
|
|
1578
|
-
describe('_.put.sync', () => {
|
|
1579
|
-
aname(_.put.sync, 'put')
|
|
1580
|
-
aname(_.put.sync(['a', 1], ['b', 2]), 'put([a, () => 1], [b, () => 2])')
|
|
1581
|
-
it('puts a property on current payload, passing in payload', async () => {
|
|
1582
|
-
ade(
|
|
1583
|
-
_.put.sync(
|
|
1584
|
-
['hey', x => x.ho + 1],
|
|
1585
|
-
['yo', x => x.ho + 2],
|
|
1586
|
-
)({ ho: 1 }),
|
|
1587
|
-
({ hey: 2, ho: 1, yo: 3 }),
|
|
1588
|
-
)
|
|
1589
|
-
})
|
|
1590
|
-
})
|
|
1591
|
-
|
|
1592
|
-
describe('_.concat', () => {
|
|
1593
|
-
aname(_.concat, 'concat')
|
|
1594
|
-
aname(_.concat('c'), 'concat(() => \'c\')')
|
|
1595
|
-
aname(_.concat([1, 2, 3]), 'concat(() => [...]{3})')
|
|
1596
|
-
aname(_.concat(_.id), 'concat(id)')
|
|
1597
|
-
it('concats fn computations to point', async () => {
|
|
1598
|
-
ase(await _.concat('c')('ab'), 'abc')
|
|
1599
|
-
ase(await _.concat('c', x => x + 'hey')('ab'), 'abcabhey')
|
|
1600
|
-
ade(await _.concat([3])([1, 2]), [1, 2, 3])
|
|
1601
|
-
ade(await _.concat(3)([1, 2]), [1, 2, 3])
|
|
1602
|
-
ade(await _.concat(3, x => [x[0] + 3])([1, 2]), [1, 2, 3, 4])
|
|
1603
|
-
})
|
|
1604
|
-
it('throws TypeError', async () => {
|
|
1605
|
-
assert.rejects(
|
|
1606
|
-
() => _.concat(1)(0),
|
|
1607
|
-
new TypeError('cannot concat to 0'),
|
|
1608
|
-
)
|
|
1609
|
-
assert.rejects(
|
|
1610
|
-
() => _.concat(1)(null),
|
|
1611
|
-
new TypeError('cannot concat to null'),
|
|
1612
|
-
)
|
|
1613
|
-
assert.rejects(
|
|
1614
|
-
() => _.concat(1)(undefined),
|
|
1615
|
-
new TypeError('cannot concat to undefined'),
|
|
1616
|
-
)
|
|
1617
|
-
})
|
|
1618
|
-
})
|
|
1619
|
-
|
|
1620
|
-
describe('_.concat.sync', () => {
|
|
1621
|
-
aname(_.concat.sync, 'concat')
|
|
1622
|
-
aname(_.concat.sync('c'), 'concat(() => \'c\')')
|
|
1623
|
-
aname(_.concat.sync([1, 2, 3]), 'concat(() => [...]{3})')
|
|
1624
|
-
aname(_.concat.sync(_.id), 'concat(id)')
|
|
1625
|
-
it('concats fn computations to point', async () => {
|
|
1626
|
-
ase(_.concat.sync('c')('ab'), 'abc')
|
|
1627
|
-
ase(_.concat.sync('c', x => x + 'hey')('ab'), 'abcabhey')
|
|
1628
|
-
ade(_.concat.sync([3])([1, 2]), [1, 2, 3])
|
|
1629
|
-
ade(_.concat.sync(3)([1, 2]), [1, 2, 3])
|
|
1630
|
-
ade(_.concat.sync(3, x => [x[0] + 3])([1, 2]), [1, 2, 3, 4])
|
|
1631
|
-
})
|
|
1632
|
-
it('throws TypeError', async () => {
|
|
1633
|
-
assert.throws(
|
|
1634
|
-
() => _.concat.sync(1)(0),
|
|
1635
|
-
new TypeError('cannot concat to 0'),
|
|
1636
|
-
)
|
|
1637
|
-
assert.throws(
|
|
1638
|
-
() => _.concat.sync(1)(null),
|
|
1639
|
-
new TypeError('cannot concat to null'),
|
|
1640
|
-
)
|
|
1641
|
-
assert.throws(
|
|
1642
|
-
() => _.concat.sync(1)(undefined),
|
|
1643
|
-
new TypeError('cannot concat to undefined'),
|
|
1644
|
-
)
|
|
1645
|
-
})
|
|
1646
|
-
})
|
|
1647
|
-
|
|
1648
|
-
describe('_.has', () => {
|
|
1649
|
-
aname(_.has, 'has')
|
|
1650
|
-
aname(_.has('hey'), 'has(\'hey\')')
|
|
1651
|
-
aname(_.has(0), 'has(0)')
|
|
1652
|
-
it('checks for membership', async () => {
|
|
1653
|
-
ase(_.has('hey')('heyhey'), true)
|
|
1654
|
-
ase(_.has('hey')(Buffer.from('heyhey')), true)
|
|
1655
|
-
ase(_.has('hey')('yoyo'), false)
|
|
1656
|
-
ase(_.has('hey')(['hey', 1, 2]), true)
|
|
1657
|
-
ase(_.has('hey')(['yo', 1, 2]), false)
|
|
1658
|
-
ase(_.has('hey')(new Set(['hey', 1, 2])), true)
|
|
1659
|
-
ase(_.has('hey')(new Set(['yo', 1, 2])), false)
|
|
1660
|
-
ase(_.has('hey')(new Map([['hey', 1]])), true)
|
|
1661
|
-
ase(_.has('hey')(new Map([['yo', 1]])), false)
|
|
1662
|
-
ase(_.has('hey')({ hey: 1 }), true)
|
|
1663
|
-
ase(_.has('hey')({ yo: 1 }), false)
|
|
1664
|
-
})
|
|
1665
|
-
it('throws TypeError', async () => {
|
|
1666
|
-
assert.throws(
|
|
1667
|
-
() => _.has('hey')(1),
|
|
1668
|
-
new TypeError('cannot has 1'),
|
|
1669
|
-
)
|
|
1670
|
-
assert.throws(
|
|
1671
|
-
() => _.has('hey')(undefined),
|
|
1672
|
-
new TypeError('cannot has undefined'),
|
|
1673
|
-
)
|
|
1674
|
-
assert.throws(
|
|
1675
|
-
() => _.has('hey')(null),
|
|
1676
|
-
new TypeError('cannot has null'),
|
|
1677
|
-
)
|
|
1678
|
-
})
|
|
1679
|
-
})
|
|
1680
|
-
|
|
1681
|
-
describe('_.member', () => {
|
|
1682
|
-
aname(_.member, 'member')
|
|
1683
|
-
aname(_.member([1, 2, 3]), 'member([...]{3})')
|
|
1684
|
-
aname(_.member(new Set([1, 2, 3])), 'member(Set{...}{3})')
|
|
1685
|
-
aname(_.member({ a: 1 }), 'member({...}{1})')
|
|
1686
|
-
aname(_.member(new Map(Object.entries({ a: 1 }))), 'member(Map{...}{1})')
|
|
1687
|
-
it('like _.has but arguments flipped', async () => {
|
|
1688
|
-
ase(_.member('heyhey')('hey'), true)
|
|
1689
|
-
ase(_.member('yoyo')('hey'), false)
|
|
1690
|
-
ase(_.member(['hey', 1, 2])('hey'), true)
|
|
1691
|
-
ase(_.member(['yo', 1, 2])('hey'), false)
|
|
1692
|
-
ase(_.member(new Set(['hey', 1, 2]))('hey'), true)
|
|
1693
|
-
ase(_.member(new Set(['yo', 1, 2]))('hey'), false)
|
|
1694
|
-
ase(_.member(new Map([['hey', 1]]))('hey'), true)
|
|
1695
|
-
ase(_.member(new Map([['yo', 1]]))('hey'), false)
|
|
1696
|
-
ase(_.member({ hey: 1 })('hey'), true)
|
|
1697
|
-
ase(_.member({ yo: 1 })('hey'), false)
|
|
1698
|
-
})
|
|
1699
|
-
})
|
|
1700
|
-
|
|
1701
|
-
describe('_.trace', () => {
|
|
1702
|
-
aname(_.trace, 'trace')
|
|
1703
|
-
it('console logs args', async () => {
|
|
1704
|
-
let stdout = captureStdout()
|
|
1705
|
-
ase(_.trace('trace')('trace'), 'trace')
|
|
1706
|
-
ase(stdout.output, 'trace \'trace\'\n')
|
|
1707
|
-
releaseStdout()
|
|
1708
|
-
stdout = captureStdout()
|
|
1709
|
-
ade(_.trace('trace')({ a: 1, b: [[[[['hey']]]]] }), { a: 1, b: [[[[['hey']]]]] })
|
|
1710
|
-
ase(stdout.output, 'trace {\n a: 1,\n b: [\n [\n [ [ [ \'hey\' ] ] ]\n ]\n ]\n}\n')
|
|
1711
|
-
releaseStdout()
|
|
1712
|
-
})
|
|
1713
|
-
})
|
|
1714
|
-
|
|
1715
|
-
describe('_.tracep', () => {
|
|
1716
|
-
aname(_.tracep, 'tracep')
|
|
1717
|
-
aname(_.tracep('hey'), 'tracep(\'hey\')')
|
|
1718
|
-
aname(_.tracep('hey', 'tag'), 'tracep(\'hey\', \'tag\')')
|
|
1719
|
-
aname(_.tracep(1), 'tracep(1)')
|
|
1720
|
-
it('console logs prop and x.prop, opt tag', async () => {
|
|
1721
|
-
let stdout = captureStdout()
|
|
1722
|
-
ade(_.tracep('hey')({ hey: 'tracep' }), { hey: 'tracep' })
|
|
1723
|
-
ase(stdout.output, '.hey - \'tracep\'\n')
|
|
1724
|
-
releaseStdout()
|
|
1725
|
-
stdout = captureStdout()
|
|
1726
|
-
ade(_.tracep('hey', 'mytag')({ hey: 'tracep' }), { hey: 'tracep' })
|
|
1727
|
-
ase(stdout.output, 'mytag .hey - \'tracep\'\n')
|
|
1728
|
-
releaseStdout()
|
|
1729
|
-
})
|
|
1730
|
-
})
|
|
1731
|
-
|
|
1732
|
-
describe('_.tracef', () => {
|
|
1733
|
-
aname(_.tracef, 'tracef')
|
|
1734
|
-
aname(_.tracef(_.id), 'tracef(id)')
|
|
1735
|
-
aname(_.tracef(_.id, 'tag'), 'tracef(id, \'tag\')')
|
|
1736
|
-
it('console logs fn(args)', async () => {
|
|
1737
|
-
let stdout = captureStdout()
|
|
1738
|
-
ase(await _.tracef(async x => x)('tracef'), 'tracef')
|
|
1739
|
-
ase(stdout.output, '\'tracef\'\n')
|
|
1740
|
-
releaseStdout()
|
|
1741
|
-
})
|
|
1742
|
-
})
|
|
1743
|
-
|
|
1744
|
-
describe('_.tracef.sync', async () => {
|
|
1745
|
-
aname(_.tracef.sync, 'tracef')
|
|
1746
|
-
aname(_.tracef.sync(_.id), 'tracef(id)')
|
|
1747
|
-
aname(_.tracef.sync(_.id, 'tag'), 'tracef(id, \'tag\')')
|
|
1748
|
-
it('console logs sync fn(args)', async() => {
|
|
1749
|
-
let stdout = captureStdout()
|
|
1750
|
-
ase(_.tracef.sync(_.id)('tracef'), 'tracef')
|
|
1751
|
-
ase(stdout.output, '\'tracef\'\n')
|
|
1752
|
-
releaseStdout()
|
|
1753
|
-
})
|
|
1754
|
-
})
|
|
1755
|
-
|
|
1756
|
-
describe('_.promisify', () => {
|
|
1757
|
-
aname(_.promisify, 'promisify')
|
|
1758
|
-
const cbHey = cb => setTimeout(() => cb(null, 'hey'), 10)
|
|
1759
|
-
it('promisifies', async () => {
|
|
1760
|
-
ase(await _.promisify(cbHey)(), 'hey')
|
|
1761
|
-
try {
|
|
1762
|
-
const fn = _.promisify('wut')
|
|
1763
|
-
assert(!fn)
|
|
1764
|
-
} catch (e) {
|
|
1765
|
-
assert(e instanceof TypeError)
|
|
1766
|
-
}
|
|
1767
|
-
})
|
|
1768
|
-
})
|
|
1769
|
-
|
|
1770
|
-
describe('_.callbackify', () => {
|
|
1771
|
-
aname(_.callbackify, 'callbackify')
|
|
1772
|
-
const promiseHey = () => new Promise(res => setTimeout(() => res('hey'), 10))
|
|
1773
|
-
it('callbackifies', (done) => {
|
|
1774
|
-
_.callbackify(promiseHey)((err, hey) => {
|
|
1775
|
-
assert.ifError(err)
|
|
1776
|
-
ase(hey, 'hey')
|
|
1777
|
-
done()
|
|
1778
|
-
})
|
|
1779
|
-
})
|
|
1780
|
-
})
|
|
1781
|
-
|
|
1782
|
-
describe('_.promisifyAll', () => {
|
|
1783
|
-
aname(_.promisifyAll, 'promisifyAll')
|
|
1784
|
-
function cbModule(){}
|
|
1785
|
-
cbModule.cbHey = cb => setTimeout(() => cb(null, 'hey'), 10)
|
|
1786
|
-
cbModule.hey = 'hey'
|
|
1787
|
-
it('promisifies an entire module', async () => {
|
|
1788
|
-
ase(await _.promisifyAll(cbModule).cbHey(), 'hey')
|
|
1789
|
-
ase(_.promisifyAll(cbModule).hey, 'hey')
|
|
1790
|
-
})
|
|
1791
|
-
})
|
|
1792
|
-
|
|
1793
|
-
describe('_.callbackifyAll', () => {
|
|
1794
|
-
aname(_.callbackifyAll, 'callbackifyAll')
|
|
1795
|
-
function promiseModule(){}
|
|
1796
|
-
promiseModule.promiseHey = () => new Promise(res => setTimeout(() => res('hey'), 10))
|
|
1797
|
-
promiseModule.hey = 'hey'
|
|
1798
|
-
it('callbackifies an entire module', (done) => {
|
|
1799
|
-
ase(_.callbackifyAll(promiseModule).hey, 'hey')
|
|
1800
|
-
_.callbackifyAll(promiseModule).promiseHey((err, hey) => {
|
|
1801
|
-
assert.ifError(err)
|
|
1802
|
-
ase(hey, 'hey')
|
|
1803
|
-
done()
|
|
1804
|
-
})
|
|
1805
|
-
})
|
|
1806
|
-
})
|
|
1807
|
-
|
|
1808
|
-
describe('_.pick', () => {
|
|
1809
|
-
aname(_.pick, 'pick')
|
|
1810
|
-
aname(_.pick(1, 2), 'pick(1, 2)')
|
|
1811
|
-
aname(_.pick('hey', 'ho'), 'pick(\'hey\', \'ho\')')
|
|
1812
|
-
it('makes a new object using picked properties', async () => {
|
|
1813
|
-
ade(_.pick('a', 'b')({ a: 1, b: 2, c: 2 }), { a: 1, b: 2 })
|
|
1814
|
-
ade(_.pick('d')({ a: 1, b: 2, c: 2 }), {})
|
|
1815
|
-
})
|
|
1816
|
-
it('throws a TypeError', async () => {
|
|
1817
|
-
assert.throws(
|
|
1818
|
-
() => _.pick('a', 'b')('hey'),
|
|
1819
|
-
new TypeError('cannot pick hey')
|
|
1820
|
-
)
|
|
1821
|
-
})
|
|
1822
|
-
})
|
|
1823
|
-
|
|
1824
|
-
describe('_.exclude', () => {
|
|
1825
|
-
aname(_.exclude, 'exclude')
|
|
1826
|
-
aname(_.exclude(1, 2), 'exclude(1, 2)')
|
|
1827
|
-
aname(_.exclude('hey', 'ho'), 'exclude(\'hey\', \'ho\')')
|
|
1828
|
-
it('excludes keys from an object', async () => {
|
|
1829
|
-
ade(_.exclude('a')({ a: 1, b: 2 }), { b: 2 })
|
|
1830
|
-
ade(_.exclude('a', 'b')({ a: 1, b: 2 }), {})
|
|
1831
|
-
})
|
|
1832
|
-
it('throws a TypeError', async () => {
|
|
1833
|
-
assert.throws(
|
|
1834
|
-
() => _.exclude('a', 'b')('hey'),
|
|
1835
|
-
new TypeError('cannot exclude hey')
|
|
1836
|
-
)
|
|
1837
|
-
})
|
|
1838
|
-
})
|
|
1839
|
-
|
|
1840
|
-
describe('_.slice', () => {
|
|
1841
|
-
aname(_.slice, 'slice')
|
|
1842
|
-
aname(_.slice(0), 'slice(0)')
|
|
1843
|
-
aname(_.slice(1, 2), 'slice(1, 2)')
|
|
1844
|
-
it('slices an array from a to b, not including b', async () => {
|
|
1845
|
-
ade(_.slice(0)([1, 2, 3]), [1, 2, 3])
|
|
1846
|
-
ade(_.slice(0, 0)([1, 2, 3]), [])
|
|
1847
|
-
ade(_.slice(0, 1)([1, 2, 3]), [1])
|
|
1848
|
-
ade(_.slice(0, -2)([1, 2, 3]), [1])
|
|
1849
|
-
ade(_.slice(0, 2)([1, 2, 3]), [1, 2])
|
|
1850
|
-
ade(_.slice(0, -1)([1, 2, 3]), [1, 2])
|
|
1851
|
-
ade(_.slice(0, 3)([1, 2, 3]), [1, 2, 3])
|
|
1852
|
-
ade(_.slice(1)([1, 2, 3]), [2, 3])
|
|
1853
|
-
ade(_.slice(1, 0)([1, 2, 3]), [])
|
|
1854
|
-
ade(_.slice(1, 1)([1, 2, 3]), [])
|
|
1855
|
-
ade(_.slice(1, 2)([1, 2, 3]), [2])
|
|
1856
|
-
ade(_.slice(1, -1)([1, 2, 3]), [2])
|
|
1857
|
-
ade(_.slice(1, 3)([1, 2, 3]), [2, 3])
|
|
1858
|
-
ade(_.slice(-1)([1, 2, 3]), [3])
|
|
1859
|
-
ade(_.slice(-1, -1)([1, 2, 3]), [])
|
|
1860
|
-
ade(_.slice(-2)([1, 2, 3]), [2, 3])
|
|
1861
|
-
ade(_.slice(-2, -1)([1, 2, 3]), [2])
|
|
1862
|
-
ade(_.slice(-3)([1, 2, 3]), [1, 2, 3])
|
|
1863
|
-
ade(_.slice(-3, -1)([1, 2, 3]), [1, 2])
|
|
1864
|
-
ade(_.slice(-3, -2)([1, 2, 3]), [1])
|
|
1865
|
-
ade(_.slice(-3, -2)([1, 2, 3]), [1])
|
|
1866
|
-
ade(_.slice(0, Infinity)([1, 2, 3]), [1, 2, 3])
|
|
1867
|
-
ade(_.slice(-Infinity, Infinity)([1, 2, 3]), [1, 2, 3])
|
|
1868
|
-
ase(_.slice(0)('hey'), 'hey')
|
|
1869
|
-
ase(_.slice(1)('hey'), 'ey')
|
|
1870
|
-
})
|
|
1871
|
-
})
|
|
1872
|
-
|
|
1873
|
-
describe('_.replaceOne', () => {
|
|
1874
|
-
aname(_.replaceOne, 'replaceOne')
|
|
1875
|
-
aname(_.replaceOne('hey', ''), 'replaceOne(\'hey\', \'\')')
|
|
1876
|
-
aname(_.replaceOne('hey', 1), 'replaceOne(\'hey\', 1)')
|
|
1877
|
-
it('replaces the first occurence a with b', async () => {
|
|
1878
|
-
ase(_.replaceOne('hey', '')('heyheyhey'), 'heyhey')
|
|
1879
|
-
ase(_.replaceOne('hey', 1)('heyheyhey'), '1heyhey')
|
|
1880
|
-
ase(_.replaceOne('', '')('heyheyhey'), 'heyheyhey')
|
|
1881
|
-
})
|
|
1882
|
-
it('throws TypeError', async () => {
|
|
1883
|
-
assert.throws(
|
|
1884
|
-
() => _.replaceOne('hey', '')(),
|
|
1885
|
-
new TypeError('cannot replace for undefined'),
|
|
1886
|
-
)
|
|
1887
|
-
assert.throws(
|
|
1888
|
-
() => ase(_.replaceOne('hey', false)('heyheyhey'), 'falseheyhey'),
|
|
1889
|
-
new TypeError('bad replacement false'),
|
|
1890
|
-
)
|
|
1891
|
-
assert.throws(
|
|
1892
|
-
() => _.replaceOne('hey')(),
|
|
1893
|
-
new TypeError('no replacement provided'),
|
|
1894
|
-
)
|
|
1895
|
-
})
|
|
1896
|
-
})
|
|
1897
|
-
|
|
1898
|
-
describe('_.replaceAll', () => {
|
|
1899
|
-
aname(_.replaceAll, 'replaceAll')
|
|
1900
|
-
aname(_.replaceAll('hey', ''), 'replaceAll(\'hey\', \'\')')
|
|
1901
|
-
aname(_.replaceAll('hey', 1), 'replaceAll(\'hey\', 1)')
|
|
1902
|
-
it('replaces the first occurence a with b', async () => {
|
|
1903
|
-
ase(_.replaceAll('hey', '')('heyheyhey'), '')
|
|
1904
|
-
ase(_.replaceAll('hey', 1)('heyheyhey'), '111')
|
|
1905
|
-
ase(_.replaceAll('', '')('heyheyhey'), 'heyheyhey')
|
|
1906
|
-
})
|
|
1907
|
-
it('throws TypeError', async () => {
|
|
1908
|
-
assert.throws(
|
|
1909
|
-
() => _.replaceAll('hey', '')(),
|
|
1910
|
-
new TypeError('cannot replace for undefined'),
|
|
1911
|
-
)
|
|
1912
|
-
assert.throws(
|
|
1913
|
-
() => ase(_.replaceAll('hey', false)('heyheyhey'), 'falseheyhey'),
|
|
1914
|
-
new TypeError('bad replacement false'),
|
|
1915
|
-
)
|
|
1916
|
-
assert.throws(
|
|
1917
|
-
() => _.replaceAll('hey')(),
|
|
1918
|
-
new TypeError('no replacement provided'),
|
|
1919
|
-
)
|
|
1920
|
-
})
|
|
1921
|
-
})
|
|
1922
|
-
|
|
1923
|
-
describe('_.join', () => {
|
|
1924
|
-
aname(_.join, 'join')
|
|
1925
|
-
aname(_.join(','), 'join(\',\')')
|
|
1926
|
-
it('joins elements of an array on delim', async () => {
|
|
1927
|
-
ade(_.join(',')([1, 2, 3]), '1,2,3')
|
|
1928
|
-
})
|
|
1929
|
-
it('throws TypeError', async () => {
|
|
1930
|
-
assert.throws(
|
|
1931
|
-
() => ade(_.join()([1, 2, 3]), '1,2,3'),
|
|
1932
|
-
new TypeError('no delimiter provided'),
|
|
1933
|
-
)
|
|
1934
|
-
assert.throws(
|
|
1935
|
-
() => ade(_.join(false)([1, 2, 3]), '1,2,3'),
|
|
1936
|
-
new TypeError('bad delimiter false'),
|
|
1937
|
-
)
|
|
1938
|
-
})
|
|
1939
|
-
})
|
|
1940
|
-
|
|
1941
|
-
describe('_.split', () => {
|
|
1942
|
-
aname(_.split, 'split')
|
|
1943
|
-
aname(_.split(','), 'split(\',\')')
|
|
1944
|
-
it('splits a string into an array from given delimiter', async () => {
|
|
1945
|
-
ade(_.split('.')('a.b.c'), ['a', 'b', 'c'])
|
|
1946
|
-
ade(_.split(1)('a1b'), ['a', 'b'])
|
|
1947
|
-
})
|
|
1948
|
-
it('throws TypeError', async () => {
|
|
1949
|
-
assert.throws(
|
|
1950
|
-
() => ade(_.split()('a.b.c'), ['a.b.c']),
|
|
1951
|
-
new TypeError('no delimiter provided'),
|
|
1952
|
-
)
|
|
1953
|
-
assert.throws(
|
|
1954
|
-
() => ade(_.split('.')(), ['']),
|
|
1955
|
-
new TypeError('cannot split undefined'),
|
|
1956
|
-
)
|
|
1957
|
-
assert.throws(
|
|
1958
|
-
() => ade(_.split('.')(1), ['1']),
|
|
1959
|
-
new TypeError('cannot split 1'),
|
|
1960
|
-
)
|
|
1961
|
-
assert.throws(
|
|
1962
|
-
() => ade(_.split(false)('hey')),
|
|
1963
|
-
new TypeError('bad delimiter false'),
|
|
1964
|
-
)
|
|
1965
|
-
})
|
|
1966
|
-
})
|
|
1967
|
-
|
|
1968
|
-
describe('_.lowercase', () => {
|
|
1969
|
-
aname(_.lowercase, 'lowercase')
|
|
1970
|
-
it('lowercases', async () => {
|
|
1971
|
-
ase(_.lowercase('AAA'), 'aaa')
|
|
1972
|
-
ase(_.lowercase('Aaa'), 'aaa')
|
|
1973
|
-
ase(_.lowercase('Aaa '), 'aaa ')
|
|
1974
|
-
})
|
|
1975
|
-
it('throws TypeError', async () => {
|
|
1976
|
-
assert.throws(
|
|
1977
|
-
() => _.lowercase(null),
|
|
1978
|
-
new TypeError('cannot lowercase null'),
|
|
1979
|
-
)
|
|
1980
|
-
assert.throws(
|
|
1981
|
-
() => _.lowercase(),
|
|
1982
|
-
new TypeError('cannot lowercase undefined'),
|
|
1983
|
-
)
|
|
1984
|
-
})
|
|
1985
|
-
})
|
|
1986
|
-
|
|
1987
|
-
describe('_.uppercase', () => {
|
|
1988
|
-
aname(_.uppercase, 'uppercase')
|
|
1989
|
-
it('uppercases', async () => {
|
|
1990
|
-
ase(_.uppercase('aaa'), 'AAA')
|
|
1991
|
-
ase(_.uppercase('Aaa'), 'AAA')
|
|
1992
|
-
ase(_.uppercase('Aaa '), 'AAA ')
|
|
1993
|
-
})
|
|
1994
|
-
it('throws TypeError', async () => {
|
|
1995
|
-
assert.throws(
|
|
1996
|
-
() => _.uppercase(null),
|
|
1997
|
-
new TypeError('cannot uppercase null'),
|
|
1998
|
-
)
|
|
1999
|
-
assert.throws(
|
|
2000
|
-
() => _.uppercase(),
|
|
2001
|
-
new TypeError('cannot uppercase undefined'),
|
|
2002
|
-
)
|
|
2003
|
-
})
|
|
2004
|
-
})
|
|
2005
|
-
|
|
2006
|
-
describe('_.capitalize', () => {
|
|
2007
|
-
aname(_.capitalize, 'capitalize')
|
|
2008
|
-
it('capitalizes', async () => {
|
|
2009
|
-
ase(_.capitalize('george'), 'George')
|
|
2010
|
-
ase(_.capitalize('george benson'), 'George benson')
|
|
2011
|
-
ase(_.capitalize(''), '')
|
|
2012
|
-
})
|
|
2013
|
-
it('throws TypeError', async () => {
|
|
2014
|
-
assert.throws(
|
|
2015
|
-
() => _.capitalize(null),
|
|
2016
|
-
new TypeError('cannot capitalize null'),
|
|
2017
|
-
)
|
|
2018
|
-
assert.throws(
|
|
2019
|
-
() => _.capitalize(),
|
|
2020
|
-
new TypeError('cannot capitalize undefined'),
|
|
2021
|
-
)
|
|
2022
|
-
})
|
|
2023
|
-
})
|
|
2024
|
-
|
|
2025
|
-
describe('_.braid', () => {
|
|
2026
|
-
aname(_.braid, 'braid')
|
|
2027
|
-
aname(_.braid(1, 2), 'braid(1, 2)')
|
|
2028
|
-
it('braids two or more arrays into one single array', async () => {
|
|
2029
|
-
ade(_.braid(1)([[1]]), [1])
|
|
2030
|
-
ade(
|
|
2031
|
-
_.braid(1, 2)([
|
|
2032
|
-
Array(2).fill('a'),
|
|
2033
|
-
Array(4).fill('b'),
|
|
2034
|
-
]),
|
|
2035
|
-
['a', 'b', 'b', 'a', 'b', 'b'],
|
|
2036
|
-
)
|
|
2037
|
-
ade(
|
|
2038
|
-
_.braid(1, 1)([
|
|
2039
|
-
_.braid(1, 2)([
|
|
2040
|
-
Array(2).fill('a'),
|
|
2041
|
-
Array(4).fill('b'),
|
|
2042
|
-
]),
|
|
2043
|
-
Array(2).fill('c'),
|
|
2044
|
-
]),
|
|
2045
|
-
['a', 'c', 'b', 'c', 'b', 'a', 'b', 'b'],
|
|
2046
|
-
)
|
|
2047
|
-
})
|
|
2048
|
-
it('throws TypeError', async () => {
|
|
2049
|
-
assert.throws(
|
|
2050
|
-
() => _.braid(1, 1)({}),
|
|
2051
|
-
new TypeError('point must be an array of arrays'),
|
|
2052
|
-
)
|
|
2053
|
-
assert.throws(
|
|
2054
|
-
() => _.braid(1, 1)([[], [], undefined]),
|
|
2055
|
-
new TypeError('point must be an array of arrays'),
|
|
2056
|
-
)
|
|
2057
|
-
})
|
|
2058
|
-
it('throws Error', async () => {
|
|
2059
|
-
assert.throws(
|
|
2060
|
-
() => _.braid(1, 1, 1)([[], []]),
|
|
2061
|
-
new Error('point length must === number of rates'),
|
|
2062
|
-
)
|
|
2063
|
-
})
|
|
2064
|
-
})
|
|
2065
|
-
|
|
2066
|
-
describe('_.unbraid', () => {
|
|
2067
|
-
aname(_.unbraid, 'unbraid')
|
|
2068
|
-
aname(_.unbraid(1, 2), 'unbraid(1, 2)')
|
|
2069
|
-
it('unbraids an array into multiple arrays', async () => {
|
|
2070
|
-
ade(
|
|
2071
|
-
_.unbraid(1, 2)(['a', 'b', 'b', 'a', 'b', 'b']),
|
|
2072
|
-
[Array(2).fill('a'), Array(4).fill('b')],
|
|
2073
|
-
)
|
|
2074
|
-
})
|
|
2075
|
-
it('throws TypeError', async () => {
|
|
2076
|
-
assert.throws(
|
|
2077
|
-
() => _.unbraid(1, 1)({}),
|
|
2078
|
-
new TypeError('point must be an array'),
|
|
2079
|
-
)
|
|
2080
|
-
})
|
|
2081
|
-
})
|
|
2082
|
-
|
|
2083
|
-
describe('_.transpose', () => {
|
|
2084
|
-
aname(_.transpose, 'transpose')
|
|
2085
|
-
it('transposes a 2d array', async () => {
|
|
2086
|
-
ade(
|
|
2087
|
-
_.transpose([
|
|
2088
|
-
[1, 2, 3],
|
|
2089
|
-
[1, 2, 3],
|
|
2090
|
-
[1, 2, 3],
|
|
2091
|
-
]), [
|
|
2092
|
-
[1, 1, 1],
|
|
2093
|
-
[2, 2, 2],
|
|
2094
|
-
[3, 3, 3],
|
|
2095
|
-
]
|
|
2096
|
-
)
|
|
2097
|
-
ade(
|
|
2098
|
-
_.transpose([
|
|
2099
|
-
[1, 2, 3],
|
|
2100
|
-
[1, 2, 3],
|
|
2101
|
-
]), [
|
|
2102
|
-
[1, 1],
|
|
2103
|
-
[2, 2],
|
|
2104
|
-
[3, 3],
|
|
2105
|
-
]
|
|
2106
|
-
)
|
|
2107
|
-
})
|
|
2108
|
-
it('throws TypeError', async () => {
|
|
2109
|
-
assert.throws(
|
|
2110
|
-
() => _.transpose('hey'),
|
|
2111
|
-
new TypeError('point must be an array'),
|
|
2112
|
-
)
|
|
2113
|
-
})
|
|
2114
|
-
})
|
|
2115
|
-
|
|
2116
|
-
describe('_.flatten', () => {
|
|
2117
|
-
aname(_.flatten, 'flatten')
|
|
2118
|
-
it('flattens an array of arrays', async () => {
|
|
2119
|
-
ade(
|
|
2120
|
-
_.flatten([[1], [2], [3]]),
|
|
2121
|
-
[1, 2, 3],
|
|
2122
|
-
)
|
|
2123
|
-
})
|
|
2124
|
-
it('throws TypeError', async () => {
|
|
2125
|
-
assert.throws(
|
|
2126
|
-
() => _.flatten('hey'),
|
|
2127
|
-
new TypeError('point must be an array'),
|
|
2128
|
-
)
|
|
2129
|
-
})
|
|
2130
|
-
})
|
|
2131
|
-
|
|
2132
|
-
describe('_.flattenAll', () => {
|
|
2133
|
-
aname(_.flattenAll, 'flattenAll')
|
|
2134
|
-
it('flattens an array of arrays of any depth', async () => {
|
|
2135
|
-
ade(
|
|
2136
|
-
_.flattenAll([1, [2, [3]]]),
|
|
2137
|
-
[1, 2, 3],
|
|
2138
|
-
)
|
|
2139
|
-
})
|
|
2140
|
-
it('throws TypeError', async () => {
|
|
2141
|
-
assert.throws(
|
|
2142
|
-
() => _.flattenAll('hey'),
|
|
2143
|
-
new TypeError('point must be an array'),
|
|
2144
|
-
)
|
|
2145
|
-
})
|
|
2146
|
-
})
|
|
2147
|
-
|
|
2148
|
-
describe('_.uniq', () => {
|
|
2149
|
-
aname(_.uniq, 'uniq')
|
|
2150
|
-
it('uniques an array', async () => {
|
|
2151
|
-
ade(
|
|
2152
|
-
_.uniq([1, 1, 1, 2, 2, 2, 3, 3, 3]),
|
|
2153
|
-
[1, 2, 3],
|
|
2154
|
-
)
|
|
2155
|
-
})
|
|
2156
|
-
it('throws TypeError', async () => {
|
|
2157
|
-
assert.throws(
|
|
2158
|
-
() => _.uniq('hey'),
|
|
2159
|
-
new TypeError('point must be an array'),
|
|
2160
|
-
)
|
|
2161
|
-
})
|
|
2162
|
-
})
|
|
2163
|
-
|
|
2164
|
-
describe('_.first', () => {
|
|
2165
|
-
aname(_.first, 'first')
|
|
2166
|
-
it('gets the first item', async () => {
|
|
2167
|
-
ase(_.first([1, 2, 3]), 1)
|
|
2168
|
-
})
|
|
2169
|
-
it('throws TypeError', async () => {
|
|
2170
|
-
assert.throws(
|
|
2171
|
-
() => _.first('hey'),
|
|
2172
|
-
new TypeError('point must be an array'),
|
|
2173
|
-
)
|
|
2174
|
-
})
|
|
2175
|
-
})
|
|
2176
|
-
|
|
2177
|
-
describe('_.last', () => {
|
|
2178
|
-
aname(_.last, 'last')
|
|
2179
|
-
it('gets the first item', async () => {
|
|
2180
|
-
ase(_.last([1, 2, 3]), 3)
|
|
2181
|
-
})
|
|
2182
|
-
it('throws TypeError', async () => {
|
|
2183
|
-
assert.throws(
|
|
2184
|
-
() => _.first('hey'),
|
|
2185
|
-
new TypeError('point must be an array'),
|
|
2186
|
-
)
|
|
2187
|
-
})
|
|
2188
|
-
})
|
|
2189
|
-
|
|
2190
|
-
describe('_.reverse', () => {
|
|
2191
|
-
aname(_.reverse, 'reverse')
|
|
2192
|
-
it('=> reversed array', async () => {
|
|
2193
|
-
ade(_.reverse([1, 2, 3]), [3, 2, 1])
|
|
2194
|
-
})
|
|
2195
|
-
it('throws TypeError', async () => {
|
|
2196
|
-
assert.throws(
|
|
2197
|
-
() => _.reverse('hey'),
|
|
2198
|
-
new TypeError('point must be an array'),
|
|
2199
|
-
)
|
|
2200
|
-
})
|
|
2201
|
-
})
|
|
2202
|
-
|
|
2203
|
-
describe('_.sort', () => {
|
|
2204
|
-
aname(_.sort, 'sort')
|
|
2205
|
-
aname(_.sort(1), 'sort(1)')
|
|
2206
|
-
it('sorts an array', async () => {
|
|
2207
|
-
ade(_.sort(-1)([2, 1, 3]), [3, 2, 1])
|
|
2208
|
-
ade(_.sort(1)([2, 1, 3]), [1, 2, 3])
|
|
2209
|
-
ade(_.sort()([2, 1, 3]), [1, 2, 3])
|
|
2210
|
-
ade(_.sort(1)(['b', 'a', 'c']), ['a', 'b', 'c'])
|
|
2211
|
-
ade(_.sort(-1)(['b', 'a', 'c']), ['c', 'b', 'a'])
|
|
2212
|
-
})
|
|
2213
|
-
it('throws TypeError', async () => {
|
|
2214
|
-
assert.throws(
|
|
2215
|
-
() => _.sort(1)('hey'),
|
|
2216
|
-
new TypeError('point must be an array'),
|
|
2217
|
-
)
|
|
2218
|
-
})
|
|
2219
|
-
})
|
|
2220
|
-
|
|
2221
|
-
describe('_.sortBy', () => {
|
|
2222
|
-
aname(_.sortBy, 'sortBy')
|
|
2223
|
-
aname(_.sortBy('a'), 'sortBy(\'a\', 1)')
|
|
2224
|
-
aname(_.sortBy('a', 1), 'sortBy(\'a\', 1)')
|
|
2225
|
-
it('sorts an array of objects by property', async () => {
|
|
2226
|
-
ade(
|
|
2227
|
-
_.sortBy('a', 1)([{ a: 2 }, { a: 1 }, { a: 3 }]),
|
|
2228
|
-
[{ a: 1 }, { a: 2 }, { a: 3 }],
|
|
2229
|
-
)
|
|
2230
|
-
ade(
|
|
2231
|
-
_.sortBy('a', -1)([{ a: 2 }, { a: 1 }, { a: 3 }]),
|
|
2232
|
-
[{ a: 3 }, { a: 2 }, { a: 1 }],
|
|
2233
|
-
)
|
|
2234
|
-
ade(
|
|
2235
|
-
_.sortBy('a', 1)([{ a: 'b' }, { a: 'a' }, { a: 'c' }]),
|
|
2236
|
-
[{ a: 'a' }, { a: 'b' }, { a: 'c' }],
|
|
2237
|
-
)
|
|
2238
|
-
ade(
|
|
2239
|
-
_.sortBy('a', -1)([{ a: 'b' }, { a: 'a' }, { a: 'c' }]),
|
|
2240
|
-
[{ a: 'c' }, { a: 'b' }, { a: 'a' }],
|
|
2241
|
-
)
|
|
2242
|
-
})
|
|
2243
|
-
it('throws TypeError', async () => {
|
|
2244
|
-
assert.throws(
|
|
2245
|
-
() => _.sortBy('hey', 1)('hey'),
|
|
2246
|
-
new TypeError('point must be an array'),
|
|
2247
|
-
)
|
|
2248
|
-
})
|
|
2249
|
-
})
|
|
2250
|
-
|
|
2251
|
-
describe('_.size', () => {
|
|
2252
|
-
aname(_.size, 'size')
|
|
2253
|
-
it('gets the size (length)', async () => {
|
|
2254
|
-
ase(_.size('hey'), 3)
|
|
2255
|
-
ase(_.size([1, 2, 3]), 3)
|
|
2256
|
-
ase(_.size(new Set([1, 2, 3])), 3)
|
|
2257
|
-
ase(_.size(new Map([['a', 1]])), 1)
|
|
2258
|
-
ase(_.size({ a: 1 }), 1)
|
|
2259
|
-
assert.throws(
|
|
2260
|
-
() => _.size(undefined),
|
|
2261
|
-
new TypeError('cannot size undefined')
|
|
2262
|
-
)
|
|
2263
|
-
})
|
|
2264
|
-
})
|
|
2265
|
-
|
|
2266
|
-
describe('_.isEmpty', () => {
|
|
2267
|
-
aname(_.isEmpty, 'isEmpty')
|
|
2268
|
-
it('=> true if empty', async () => {
|
|
2269
|
-
ase(_.isEmpty(''), true)
|
|
2270
|
-
ase(_.isEmpty('a'), false)
|
|
2271
|
-
ase(_.isEmpty([]), true)
|
|
2272
|
-
ase(_.isEmpty([1]), false)
|
|
2273
|
-
ase(_.isEmpty(new Set()), true)
|
|
2274
|
-
ase(_.isEmpty(new Set([1])), false)
|
|
2275
|
-
ase(_.isEmpty(new Map()), true)
|
|
2276
|
-
ase(_.isEmpty(new Map([['a', 1]])), false)
|
|
2277
|
-
ase(_.isEmpty({}), true)
|
|
2278
|
-
ase(_.isEmpty({ a: 1 }), false)
|
|
2279
|
-
})
|
|
2280
|
-
})
|
|
2281
|
-
|
|
2282
|
-
describe('_.once', () => {
|
|
2283
|
-
aname(_.once, 'once')
|
|
2284
|
-
aname(_.once(_.id), 'once(id)')
|
|
2285
|
-
it('ensures fn is called once', async () => {
|
|
2286
|
-
let i = 0
|
|
2287
|
-
const fn = () => i + 1
|
|
2288
|
-
const onceFn = _.once(fn)
|
|
2289
|
-
ase(onceFn(), 1)
|
|
2290
|
-
ase(onceFn(), 1)
|
|
2291
|
-
ase(onceFn(), 1)
|
|
2292
|
-
})
|
|
2293
|
-
})
|
|
2294
|
-
|
|
2295
|
-
describe('_.prettifyJSON', () => {
|
|
2296
|
-
aname(_.prettifyJSON, 'prettifyJSON')
|
|
2297
|
-
it('prettifies json', async () => {
|
|
2298
|
-
ase(_.prettifyJSON(1), '1')
|
|
2299
|
-
ase(_.prettifyJSON('hey'), '"hey"')
|
|
2300
|
-
ase(_.prettifyJSON(true), 'true')
|
|
2301
|
-
ase(_.prettifyJSON(null), 'null')
|
|
2302
|
-
ase(_.prettifyJSON(), undefined)
|
|
2303
|
-
ase(_.prettifyJSON([]), '[]')
|
|
2304
|
-
ase(_.prettifyJSON({}), '{}')
|
|
2305
|
-
ase(_.prettifyJSON(new Set()), '{}')
|
|
2306
|
-
ase(_.prettifyJSON(new Map()), '{}')
|
|
2307
|
-
ase(_.prettifyJSON([1, 2, 3]), '[\n 1,\n 2,\n 3\n]')
|
|
2308
|
-
ase(_.prettifyJSON({ a: 1, b: 2 }), '{\n "a": 1,\n "b": 2\n}')
|
|
2309
|
-
})
|
|
2310
|
-
})
|
|
2311
|
-
|
|
2312
|
-
describe('_.hash', () => {
|
|
2313
|
-
aname(_.hash, 'hash')
|
|
2314
|
-
aname(_.hash('sha256'), 'hash(\'sha256\')')
|
|
2315
|
-
it('creates a hash function given algorithm', async () => {
|
|
2316
|
-
ase(_.hash('sha256')('a'), 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb')
|
|
2317
|
-
ase(_.hash('sha512')('a'), '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75')
|
|
2318
|
-
})
|
|
2319
|
-
})
|
|
2320
|
-
|
|
2321
|
-
describe('_.sha256', () => {
|
|
2322
|
-
aname(_.sha256, 'sha256')
|
|
2323
|
-
it('sha256 hashes a string', async () => {
|
|
2324
|
-
ase(_.hash('sha256')('a'), 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb')
|
|
2325
|
-
})
|
|
2326
|
-
})
|
|
2327
|
-
|
|
2328
|
-
describe('_.sha512', () => {
|
|
2329
|
-
aname(_.sha512, 'sha512')
|
|
2330
|
-
it('sha512 hashes a string', async () => {
|
|
2331
|
-
ase(_.hash('sha512')('a'), '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75')
|
|
2332
|
-
})
|
|
2333
|
-
})
|
|
2334
|
-
})
|