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/memory-usage/reduce.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const { reduce } = require('..')
|
|
2
|
-
|
|
3
|
-
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
4
|
-
|
|
5
|
-
const iterations = 1e4
|
|
6
|
-
|
|
7
|
-
const timeoutIDs = new Map()
|
|
8
|
-
|
|
9
|
-
const asyncGenerator = async function*(i) {
|
|
10
|
-
yield 1; yield 2
|
|
11
|
-
await new Promise(resolve => {
|
|
12
|
-
const id = setTimeout(resolve, 1e9)
|
|
13
|
-
timeoutIDs.set(i, id)
|
|
14
|
-
})
|
|
15
|
-
yield 3
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
setImmediate(async () => {
|
|
19
|
-
let i = 0, maxHeapUsed = 0
|
|
20
|
-
while (i < iterations) {
|
|
21
|
-
const p = reduce((a, b) => a + b, 0)(asyncGenerator(i))
|
|
22
|
-
await sleep(1)
|
|
23
|
-
p.cancel()
|
|
24
|
-
try {
|
|
25
|
-
await p
|
|
26
|
-
} catch (err) {
|
|
27
|
-
if (err.message !== 'cancelled') throw err
|
|
28
|
-
clearTimeout(timeoutIDs.get(i))
|
|
29
|
-
timeoutIDs.delete(i)
|
|
30
|
-
}
|
|
31
|
-
const { heapUsed } = process.memoryUsage()
|
|
32
|
-
console.log(`${i},${(heapUsed / 1024 / 1024).toFixed(2)}`)
|
|
33
|
-
i += 1
|
|
34
|
-
maxHeapUsed = Math.max(maxHeapUsed, heapUsed)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log('maxHeapUsed (MiB)', maxHeapUsed / 1024 / 1024)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// https://stackoverflow.com/questions/62336381/is-this-promise-cancellation-implementation-for-reducing-an-async-iterable-on-th
|
package/monad/AsyncPool.js
DELETED
|
File without changes
|
package/monad/BrokenPromise.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @name BrokenPromise
|
|
5
|
-
*
|
|
6
|
-
* @catchphrase
|
|
7
|
-
* a Promise that never comes back
|
|
8
|
-
*
|
|
9
|
-
* @synopsis
|
|
10
|
-
* new BrokenPromise() -> BrokenPromise {}
|
|
11
|
-
*
|
|
12
|
-
* @description
|
|
13
|
-
* A **BrokenPromise** is a Promise that never resolves or rejects, taking an infinite amount of time to get back to the caller.
|
|
14
|
-
*
|
|
15
|
-
* ```javascript
|
|
16
|
-
* new BrokenPromise() // a new BrokenPromise instance
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
const BrokenPromise = function () {
|
|
20
|
-
this.promise = new Promise(resolve => { this._resolve = resolve })
|
|
21
|
-
this.timeout = setTimeout(this.resolve, 1e9)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @name BrokenPromise.prototype.then
|
|
26
|
-
*
|
|
27
|
-
* @catchphrase
|
|
28
|
-
* register an unreachable resolver
|
|
29
|
-
*
|
|
30
|
-
* @synopsis
|
|
31
|
-
* new BrokenPromise().then(unreachableResolver function)
|
|
32
|
-
*
|
|
33
|
-
* @description
|
|
34
|
-
* **BrokenPromise.prototype.then** registers a Promise `.then` resolver function with the internal infinite promise. In that sense, the resolver function _technically_ never gets called. However, it is possible to manually fire the provided `unreachableResolver` with `BrokenPromise.prototype.resolve`.
|
|
35
|
-
*
|
|
36
|
-
* ```javascript
|
|
37
|
-
* new BrokenPromise().then(() => console.log('unreachable'))
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
BrokenPromise.prototype.then = function then(unreachableResolver) {
|
|
41
|
-
return this.promise.then(unreachableResolver)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @name BrokenPromise.prototype.resolve
|
|
46
|
-
*
|
|
47
|
-
* @catchphrase
|
|
48
|
-
* manually resolve a broken promise
|
|
49
|
-
*
|
|
50
|
-
* @synopsis
|
|
51
|
-
* const brokenPromise = new BrokenPromise().then(
|
|
52
|
-
* () => console.log('only reachable by .resolve'))
|
|
53
|
-
*
|
|
54
|
-
* brokenPromise.resolve()
|
|
55
|
-
* // only reachable by .resolve
|
|
56
|
-
*/
|
|
57
|
-
BrokenPromise.prototype.resolve = function resolve(value) {
|
|
58
|
-
clearTimeout(this.timeout)
|
|
59
|
-
this._resolve(value)
|
|
60
|
-
return this.promise
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = BrokenPromise
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const BrokenPromise = require('./BrokenPromise')
|
|
3
|
-
|
|
4
|
-
const nativeObjectToString = Object.prototype.toString
|
|
5
|
-
|
|
6
|
-
const objectToString = value => nativeObjectToString.call(value)
|
|
7
|
-
|
|
8
|
-
describe('BrokenPromise', () => {
|
|
9
|
-
it('new BrokenPromise() -> BrokenPromise', async () => {
|
|
10
|
-
const bp = new BrokenPromise()
|
|
11
|
-
assert.strictEqual(bp.constructor, BrokenPromise)
|
|
12
|
-
bp.resolve()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('(bp = new BrokenPromise()).then(any=>(result any)) -> Promise<result>; bp.resolve(1)', async () => {
|
|
16
|
-
const bp = new BrokenPromise()
|
|
17
|
-
let number = 0
|
|
18
|
-
bp.then(res => (number += res))
|
|
19
|
-
await bp.resolve(1)
|
|
20
|
-
assert.strictEqual(number, 1)
|
|
21
|
-
})
|
|
22
|
-
})
|
package/monad/Cancellable.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const isPromise = value => value != null && typeof value.then == 'function'
|
|
4
|
-
|
|
5
|
-
const promiseRace = Promise.race.bind(Promise)
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @name CancelToken
|
|
9
|
-
*
|
|
10
|
-
* @synopsis
|
|
11
|
-
* new CancelToken() -> CancelToken {}
|
|
12
|
-
*/
|
|
13
|
-
const CancelToken = function () {
|
|
14
|
-
this.promise = new Promise((_, reject) => { this._reject = reject })
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @name CancelToken.prototype.cancel
|
|
19
|
-
*
|
|
20
|
-
* @synopsis
|
|
21
|
-
* new CancelToken().cancel(value Error|any) -> CancelToken {}
|
|
22
|
-
*/
|
|
23
|
-
CancelToken.prototype.cancel = function cancel(value) {
|
|
24
|
-
this._reject(value)
|
|
25
|
-
return this
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @name CancellablePromise
|
|
30
|
-
*
|
|
31
|
-
* @synopsis
|
|
32
|
-
* CancellablePromise(value Promise|any)
|
|
33
|
-
* -> result Promise { cancel: Error|any=>this }
|
|
34
|
-
*/
|
|
35
|
-
const CancellablePromise = function (value) {
|
|
36
|
-
const cancelToken = new CancelToken()
|
|
37
|
-
const result = promiseRace([value, cancelToken.promise])
|
|
38
|
-
result.cancel = function cancel(err) {
|
|
39
|
-
cancelToken.cancel(err)
|
|
40
|
-
result.cancel = function getter() { return result }
|
|
41
|
-
return result
|
|
42
|
-
}
|
|
43
|
-
result.value = value
|
|
44
|
-
return result
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @name Cancellable
|
|
49
|
-
*
|
|
50
|
-
* @catchphrase
|
|
51
|
-
* make a function return cancellable Promises
|
|
52
|
-
*
|
|
53
|
-
* @synopsis
|
|
54
|
-
* Promise { cancel: any=>() } -> CancellablePromise
|
|
55
|
-
*
|
|
56
|
-
* Cancellable(
|
|
57
|
-
* func ...any=>Promise|any,
|
|
58
|
-
* ) -> cancellablePromiseFactory ...any=>CancellablePromise|any
|
|
59
|
-
*
|
|
60
|
-
* @description
|
|
61
|
-
* **Cancellable** wraps an async function to apply an effect such that all Promises returned by the wrapped async function are cancellable via the `.cancel` method.
|
|
62
|
-
*
|
|
63
|
-
* ```javascript
|
|
64
|
-
* const createInfinitePromise = () => Promise.race([])
|
|
65
|
-
*
|
|
66
|
-
* const createCancellablePromise = Cancellable(createInfinitePromise)
|
|
67
|
-
*
|
|
68
|
-
* const cancellablePromise = createCancellablePromise()
|
|
69
|
-
*
|
|
70
|
-
* cancellablePromise.cancel(new Error('cancelled')).catch(
|
|
71
|
-
* err => console.error(err)) // Error: cancelled
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
const Cancellable = func => function cancellablePromiseFactory(
|
|
75
|
-
...args
|
|
76
|
-
) {
|
|
77
|
-
const result = func(...args)
|
|
78
|
-
if (isPromise(result)) {
|
|
79
|
-
return CancellablePromise(result)
|
|
80
|
-
}
|
|
81
|
-
return result
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = Cancellable
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const heapUsedInLoop = require('../x/heapUsedInLoop')
|
|
2
|
-
const BrokenPromise = require('./BrokenPromise')
|
|
3
|
-
const Cancellable = require('./Cancellable')
|
|
4
|
-
const { reduce } = require('..')
|
|
5
|
-
|
|
6
|
-
const sleep = millis => new Promise(resolve => { setTimeout(resolve, millis) })
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @name Cancellable
|
|
10
|
-
*
|
|
11
|
-
* @memoryUsage
|
|
12
|
-
* new BrokenPromise(): 5e+5: { "max": "86.89 MiB", "avg": "46.11 MiB" }
|
|
13
|
-
* Cancellable(() => new BrokenPromise())().cancel(Error): 5e+5: { "max": "20.18 MiB", "avg": "11.64 MiB" }
|
|
14
|
-
* Cancellable(() => new BrokenPromise())().cancel(Error).catch: 5e+5: { "max": "19.93 MiB", "avg": "11.90 MiB" }
|
|
15
|
-
* Cancellable(reduce(add, 0)).cancel(Error): 5e+5: { "max": "12.11 MiB", "avg": "6.55 MiB" }
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
heapUsedInLoop.async.skip('new BrokenPromise()', 5e5, async function () {
|
|
19
|
-
const brokenPromise = new BrokenPromise()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
heapUsedInLoop.async.skip('Cancellable(() => new BrokenPromise())().cancel(Error)', 5e5, async function () {
|
|
23
|
-
const cancellablePromise = Cancellable(() => new BrokenPromise())()
|
|
24
|
-
cancellablePromise.cancel(new Error('cancelled'))
|
|
25
|
-
try {
|
|
26
|
-
await cancellablePromise
|
|
27
|
-
} catch (err) {
|
|
28
|
-
clearTimeout(cancellablePromise.value.timeout)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
heapUsedInLoop.async.skip('Cancellable(() => new BrokenPromise())().cancel(Error).catch', 5e5, async function () {
|
|
33
|
-
const cancellablePromise = Cancellable(() => new BrokenPromise())()
|
|
34
|
-
await cancellablePromise.cancel(new Error('cancelled')).catch(
|
|
35
|
-
() => clearTimeout(cancellablePromise.value.timeout))
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const indexTimeoutMap = new Map()
|
|
39
|
-
|
|
40
|
-
const infiniteAsyncGenerator = async function* (loop) {
|
|
41
|
-
yield 1; yield 2
|
|
42
|
-
await new Promise(function (resolve) {
|
|
43
|
-
const timeout = setTimeout(resolve, 1e9)
|
|
44
|
-
indexTimeoutMap.set(loop, timeout)
|
|
45
|
-
})
|
|
46
|
-
yield 3
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
heapUsedInLoop.async.skip('Cancellable(reduce(add, 0)).cancel(Error)', 5e5, async function (loop) {
|
|
50
|
-
const p = Cancellable(reduce((a, b) => a + b, 0))(infiniteAsyncGenerator(loop))
|
|
51
|
-
await sleep(1) // wait for async generator
|
|
52
|
-
p.cancel(new Error('cancelled'))
|
|
53
|
-
try {
|
|
54
|
-
await p
|
|
55
|
-
} catch (err) {
|
|
56
|
-
if (err.message !== 'cancelled') throw err
|
|
57
|
-
clearTimeout(indexTimeoutMap.get(loop))
|
|
58
|
-
indexTimeoutMap.delete(loop)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const Cancellable = require('./Cancellable')
|
|
3
|
-
|
|
4
|
-
describe('Cancellable', () => {
|
|
5
|
-
describe('Cancellable(func ...any=>Promise|any) -> ...any=>CancellablePromise|any', () => {
|
|
6
|
-
const createInfinitePromise = () => Promise.race([])
|
|
7
|
-
it('func ()=>Promise', async () => {
|
|
8
|
-
const createCancellablePromise = Cancellable(createInfinitePromise)
|
|
9
|
-
const cancellablePromise = createCancellablePromise()
|
|
10
|
-
assert.strictEqual(cancellablePromise.cancel.name, 'cancel')
|
|
11
|
-
const cancellablePromise2 = cancellablePromise.cancel(new Error('cancelled'))
|
|
12
|
-
assert.strictEqual(cancellablePromise, cancellablePromise2)
|
|
13
|
-
assert.rejects(() => cancellablePromise2, new Error('cancelled'))
|
|
14
|
-
})
|
|
15
|
-
it('func any=>any', async () => {
|
|
16
|
-
const identity = Cancellable(value => value)
|
|
17
|
-
assert.strictEqual(identity(null), null)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
})
|
package/monad/Function.js
DELETED
|
File without changes
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
const timeInLoop = require('../x/timeInLoop')
|
|
2
|
-
const Instance = require('./Instance')
|
|
3
|
-
const _ = require('lodash')
|
|
4
|
-
const R = require('ramda')
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* @name Instance.isString
|
|
8
|
-
*
|
|
9
|
-
* @node_version 14.3.0
|
|
10
|
-
*
|
|
11
|
-
* @benchmark
|
|
12
|
-
* typeof 'hey' === 'string': 1e+7: 12.443ms
|
|
13
|
-
* typeof 'hey' == 'string': 1e+7: 11.985ms
|
|
14
|
-
* Instance.isString('hey'): 1e+7: 12.431ms
|
|
15
|
-
* _.isString('hey'): 1e+7: 12.526ms
|
|
16
|
-
*
|
|
17
|
-
* typeof undefined === 'string': 1e+7: 12.249ms
|
|
18
|
-
* typeof undefined == 'string': 1e+7: 12.203ms
|
|
19
|
-
* Instance.isString(undefined): 1e+7: 13.198ms
|
|
20
|
-
* _.isString(undefined): 1e+7: 13.353ms
|
|
21
|
-
*
|
|
22
|
-
* Instance.isString(constructedString): 1e+7: 12.88ms
|
|
23
|
-
* _.isString(constructedString): 1e+7: 12.892ms
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
// timeInLoop('typeof \'hey\' === \'string\'', 1e7, () => { typeof 'hey' === 'string' })
|
|
27
|
-
|
|
28
|
-
// timeInLoop('typeof \'hey\' == \'string\'', 1e7, () => { typeof 'hey' == 'string' })
|
|
29
|
-
|
|
30
|
-
// timeInLoop('Instance.isString(\'hey\')', 1e7, () => { Instance.isString('hey') })
|
|
31
|
-
|
|
32
|
-
// timeInLoop('_.isString(\'hey\')', 1e7, () => { _.isString('hey') })
|
|
33
|
-
|
|
34
|
-
// timeInLoop('typeof undefined === \'string\'', 1e7, () => { typeof undefined === 'string' })
|
|
35
|
-
|
|
36
|
-
// timeInLoop('typeof undefined == \'string\'', 1e7, () => { typeof undefined == 'string' })
|
|
37
|
-
|
|
38
|
-
// timeInLoop('Instance.isString(undefined)', 1e7, () => { Instance.isString(undefined) })
|
|
39
|
-
|
|
40
|
-
// timeInLoop('_.isString(undefined)', 1e7, () => { _.isString(undefined) })
|
|
41
|
-
|
|
42
|
-
const constructedString = String('hey')
|
|
43
|
-
|
|
44
|
-
// timeInLoop('Instance.isString(constructedString)', 1e7, () => { Instance.isString(constructedString) })
|
|
45
|
-
|
|
46
|
-
// timeInLoop('_.isString(constructedString)', 1e7, () => { _.isString(constructedString) })
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
* @name Instance.isNumber
|
|
50
|
-
*
|
|
51
|
-
* @node_version 14.3.0
|
|
52
|
-
*
|
|
53
|
-
* @benchmark
|
|
54
|
-
* typeof 1 === 'number': 1e+7: 11.981ms
|
|
55
|
-
* typeof 1 == 'number': 1e+7: 11.938ms
|
|
56
|
-
* Instance.isNumber(1): 1e+7: 12.426ms
|
|
57
|
-
* _.isNumber(1): 1e+7: 12.486ms
|
|
58
|
-
*
|
|
59
|
-
* typeof undefined === 'number': 1e+7: 11.817ms
|
|
60
|
-
* typeof undefined == 'number': 1e+7: 11.819ms
|
|
61
|
-
* Instance.isNumber(undefined): 1e+7: 13.263ms
|
|
62
|
-
* _.isNumber(undefined): 1e+7: 13.424ms
|
|
63
|
-
*
|
|
64
|
-
* typeof constructedNumber === 'number': 1e+7: 11.992ms
|
|
65
|
-
* typeof constructedNumber == 'number': 1e+7: 12.029ms
|
|
66
|
-
* Instance.isNumber(constructedNumber): 1e+7: 12.483ms
|
|
67
|
-
* _.isNumber(constructedNumber): 1e+7: 12.515ms
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
// timeInLoop('typeof 1 === \'number\'', 1e7, () => { typeof 1 === 'number' })
|
|
71
|
-
|
|
72
|
-
// timeInLoop('typeof 1 == \'number\'', 1e7, () => { typeof 1 == 'number' })
|
|
73
|
-
|
|
74
|
-
// timeInLoop('Instance.isNumber(1)', 1e7, () => Instance.isNumber(1))
|
|
75
|
-
|
|
76
|
-
// timeInLoop('_.isNumber(1)', 1e7, () => _.isNumber(1))
|
|
77
|
-
|
|
78
|
-
// timeInLoop('typeof undefined === \'number\'', 1e7, () => { typeof undefined === 'number' })
|
|
79
|
-
|
|
80
|
-
// timeInLoop('typeof undefined == \'number\'', 1e7, () => { typeof undefined == 'number' })
|
|
81
|
-
|
|
82
|
-
// timeInLoop('Instance.isNumber(undefined)', 1e7, () => Instance.isNumber(undefined))
|
|
83
|
-
|
|
84
|
-
// timeInLoop('_.isNumber(undefined)', 1e7, () => _.isNumber(undefined))
|
|
85
|
-
|
|
86
|
-
const constructedNumber = Number(1)
|
|
87
|
-
|
|
88
|
-
// timeInLoop('typeof constructedNumber === \'number\'', 1e7, () => { typeof constructedNumber === 'number' })
|
|
89
|
-
|
|
90
|
-
// timeInLoop('typeof constructedNumber == \'number\'', 1e7, () => { typeof constructedNumber == 'number' })
|
|
91
|
-
|
|
92
|
-
// timeInLoop('Instance.isNumber(constructedNumber)', 1e7, () => Instance.isNumber(constructedNumber))
|
|
93
|
-
|
|
94
|
-
// timeInLoop('_.isNumber(constructedNumber)', 1e7, () => _.isNumber(constructedNumber))
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
* @name Instance.isArray
|
|
98
|
-
*
|
|
99
|
-
* @node_version 14.3.0
|
|
100
|
-
*
|
|
101
|
-
* @benchmark
|
|
102
|
-
* Array.isArray([]): 1e+7: 14.019ms
|
|
103
|
-
* Instance.isArray([]): 1e+7: 13.894ms
|
|
104
|
-
* _.isArray([]): 1e+7: 14.014ms
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
// timeInLoop('Array.isArray([])', 1e7, () => { Array.isArray([]) })
|
|
108
|
-
|
|
109
|
-
// timeInLoop('Instance.isArray([])', 1e7, () => { Instance.isArray([]) })
|
|
110
|
-
|
|
111
|
-
// timeInLoop('_.isArray([])', 1e7, () => { _.isArray([]) })
|
|
112
|
-
|
|
113
|
-
/*
|
|
114
|
-
* @name Instance.isObject
|
|
115
|
-
*
|
|
116
|
-
* @node_version 14.3.0
|
|
117
|
-
*
|
|
118
|
-
* @benchmark
|
|
119
|
-
* _.isObject({}): 1e+7: 13.329ms
|
|
120
|
-
* Instance.isObject({}): 1e+7: 13.757ms
|
|
121
|
-
*
|
|
122
|
-
* isObject1({}): 1e+8: 100.769ms
|
|
123
|
-
* isObject2({}): 1e+8: 100.656ms
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
const isObject1 = value => value != null && value.constructor == Object
|
|
127
|
-
|
|
128
|
-
const isObject2 = value => value != null && Object(value) === value
|
|
129
|
-
|
|
130
|
-
// timeInLoop('_.isObject({})', 1e7, () => { _.isObject({}) })
|
|
131
|
-
|
|
132
|
-
// timeInLoop('Instance.isObject({})', 1e7, () => { Instance.isObject({}) })
|
|
133
|
-
|
|
134
|
-
// timeInLoop('isObject1({})', 1e8, () => { isObject1({}) })
|
|
135
|
-
|
|
136
|
-
// timeInLoop('isObject2({})', 1e8, () => { isObject2({}) })
|
|
137
|
-
|
|
138
|
-
/*
|
|
139
|
-
* @name Instance.isSet
|
|
140
|
-
*
|
|
141
|
-
* @node_version 14.3.0
|
|
142
|
-
*
|
|
143
|
-
* @benchmark
|
|
144
|
-
* new Set() instanceof Set: 1e+6: 54.717ms
|
|
145
|
-
* _.isSet(new Set()): 1e+6: 62.099ms
|
|
146
|
-
* Instance.isSet(new Set()): 1e+6: 51.353ms
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
// timeInLoop('new Set() instanceof Set', 1e6, () => { new Set() instanceof Set })
|
|
150
|
-
|
|
151
|
-
// timeInLoop('_.isSet(new Set())', 1e6, () => { _.isSet(new Set()) })
|
|
152
|
-
|
|
153
|
-
// timeInLoop('Instance.isSet(new Set())', 1e6, () => { Instance.isSet(new Set()) })
|
|
154
|
-
|
|
155
|
-
/*
|
|
156
|
-
* @name Instance.isMap
|
|
157
|
-
*
|
|
158
|
-
* @node_version 14.3.0
|
|
159
|
-
*
|
|
160
|
-
* @benchmark
|
|
161
|
-
* new Map().constructor == Map: 1e+6: 57.668ms
|
|
162
|
-
* new Map().constructor === Map: 1e+6: 59.993ms
|
|
163
|
-
* new Map() instanceof Map: 1e+6: 60.385ms
|
|
164
|
-
* _.isMap(new Map()): 1e+6: 65.735ms
|
|
165
|
-
* Instance.isMap(new Map()): 1e+6: 57.714ms
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
// timeInLoop('new Map().constructor == Map', 1e6, () => { new Map().constructor == Map })
|
|
169
|
-
|
|
170
|
-
// timeInLoop('new Map().constructor === Map', 1e6, () => { new Map().constructor === Map })
|
|
171
|
-
|
|
172
|
-
// timeInLoop('new Map() instanceof Map', 1e6, () => { new Map() instanceof Map })
|
|
173
|
-
|
|
174
|
-
// timeInLoop('_.isMap(new Map())', 1e6, () => { _.isMap(new Map()) })
|
|
175
|
-
|
|
176
|
-
// timeInLoop('Instance.isMap(new Map())', 1e6, () => { Instance.isMap(new Map()) })
|
|
177
|
-
|
|
178
|
-
/*
|
|
179
|
-
* @name Instance.isIterable
|
|
180
|
-
*
|
|
181
|
-
* @node_version 14.3.0
|
|
182
|
-
*
|
|
183
|
-
* @benchmark
|
|
184
|
-
* Boolean([][Symbol.iterator]): 1e+7: 12.789ms
|
|
185
|
-
* Boolean([][symbolIterator]): 1e+7: 12.77ms
|
|
186
|
-
* !!([][Symbol.iterator]): 1e+7: 12.656ms
|
|
187
|
-
* !!([][symbolIterator]): 1e+7: 12.689ms
|
|
188
|
-
*
|
|
189
|
-
* Instance.isIterable([]): 1e+7: 13.441ms - Boolean(x[Symbol.iterator])
|
|
190
|
-
* Instance.isIterable([]): 1e+7: 13.127ms - Boolean(x[symbolIterator])
|
|
191
|
-
* Instance.isIterable([]): 1e+7: 13.841ms - !!(x[Symbol.iterator])
|
|
192
|
-
* Instance.isIterable([]): 1e+7: 14.804ms - !!(x[symbolIterator])
|
|
193
|
-
*
|
|
194
|
-
* isIterable1([]): 1e+8: 101.399ms
|
|
195
|
-
* isIterable2([]): 1e+8: 101.262ms
|
|
196
|
-
* isIterable3([]): 1e+8: 100.874ms
|
|
197
|
-
*
|
|
198
|
-
* @remarks
|
|
199
|
-
* Dereferencing Symbol.iterator vs symbolIterator is slower in some cases
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
const symbolIterator = Symbol.iterator
|
|
203
|
-
|
|
204
|
-
const isIterable1 = value => value != null && Boolean(value[symbolIterator])
|
|
205
|
-
|
|
206
|
-
const isIterable2 = value => value != null && symbolIterator in value
|
|
207
|
-
|
|
208
|
-
const isIterable3 = value => value != null && typeof value[symbolIterator] == 'function'
|
|
209
|
-
|
|
210
|
-
// timeInLoop('Boolean([][Symbol.iterator])', 1e7, () => { Boolean([][Symbol.iterator]) })
|
|
211
|
-
|
|
212
|
-
// timeInLoop('Boolean([][symbolIterator])', 1e7, () => { Boolean([][symbolIterator]) })
|
|
213
|
-
|
|
214
|
-
// timeInLoop('!!([][Symbol.iterator])', 1e7, () => { !!([][Symbol.iterator]) })
|
|
215
|
-
|
|
216
|
-
// timeInLoop('!!([][symbolIterator])', 1e7, () => { !!([][symbolIterator]) })
|
|
217
|
-
|
|
218
|
-
// timeInLoop('Instance.isIterable([])', 1e7, () => Instance.isIterable([]))
|
|
219
|
-
|
|
220
|
-
// timeInLoop('isIterable1([])', 1e8, () => isIterable1([]))
|
|
221
|
-
|
|
222
|
-
// timeInLoop('isIterable2([])', 1e8, () => isIterable2([]))
|
|
223
|
-
|
|
224
|
-
// timeInLoop('isIterable3([])', 1e8, () => isIterable3([]))
|
|
225
|
-
|
|
226
|
-
/*
|
|
227
|
-
* @name Instance.isAsyncIterable
|
|
228
|
-
*
|
|
229
|
-
* @node_version 14.3.0
|
|
230
|
-
*
|
|
231
|
-
* @benchmark
|
|
232
|
-
* Boolean([][Symbol.asyncIterator]): 1e+7: 12.784ms
|
|
233
|
-
* Boolean([][symbolAsyncIterator]): 1e+7: 14.044ms
|
|
234
|
-
* !!([][Symbol.asyncIterator]): 1e+7: 12.652ms
|
|
235
|
-
* !!([][symbolAsyncIterator]): 1e+7: 13.846ms
|
|
236
|
-
*
|
|
237
|
-
* Instance.isAsyncIterable([]): 1e+7: 13.415ms Boolean(x[Symbol.asyncIterator])
|
|
238
|
-
* Instance.isAsyncIterable([]): 1e+7: 13.061ms Boolean(x[symbolAsyncIterator])
|
|
239
|
-
* Instance.isAsyncIterable([]): 1e+7: 15.02ms !!(x[Symbol.asyncIterator])
|
|
240
|
-
* Instance.isAsyncIterable([]): 1e+7: 15.205ms !!(x[symbolAsyncIterator])
|
|
241
|
-
*
|
|
242
|
-
* isAsyncIterable1([]): 1e+8: 101.159ms
|
|
243
|
-
* isAsyncIterable2([]): 1e+8: 101.132ms
|
|
244
|
-
* isAsyncIterable3([]): 1e+8: 100.894ms
|
|
245
|
-
*/
|
|
246
|
-
|
|
247
|
-
const symbolAsyncIterator = Symbol.asyncIterator
|
|
248
|
-
|
|
249
|
-
const isAsyncIterable1 = value => value != null && Boolean(value[symbolAsyncIterator])
|
|
250
|
-
|
|
251
|
-
const isAsyncIterable2 = value => value != null && symbolAsyncIterator in value
|
|
252
|
-
|
|
253
|
-
const isAsyncIterable3 = value => value != null && typeof value[symbolAsyncIterator] == 'function'
|
|
254
|
-
|
|
255
|
-
// timeInLoop('Boolean([][Symbol.asyncIterator])', 1e7, () => { Boolean([][Symbol.asyncIterator]) })
|
|
256
|
-
|
|
257
|
-
// timeInLoop('Boolean([][symbolAsyncIterator])', 1e7, () => { Boolean([][symbolAsyncIterator]) })
|
|
258
|
-
|
|
259
|
-
// timeInLoop('!!([][Symbol.asyncIterator])', 1e7, () => { !!([][Symbol.asyncIterator]) })
|
|
260
|
-
|
|
261
|
-
// timeInLoop('!!([][symbolAsyncIterator])', 1e7, () => { !!([][symbolAsyncIterator]) })
|
|
262
|
-
|
|
263
|
-
// timeInLoop('Instance.isAsyncIterable([])', 1e7, () => Instance.isAsyncIterable([]))
|
|
264
|
-
|
|
265
|
-
// timeInLoop('isAsyncIterable1([])', 1e8, () => isAsyncIterable1([]))
|
|
266
|
-
|
|
267
|
-
// timeInLoop('isAsyncIterable2([])', 1e8, () => isAsyncIterable2([]))
|
|
268
|
-
|
|
269
|
-
// timeInLoop('isAsyncIterable3([])', 1e8, () => isAsyncIterable3([]))
|
|
270
|
-
|
|
271
|
-
/*
|
|
272
|
-
* @name Instance.isFunction
|
|
273
|
-
*
|
|
274
|
-
* @node_version 14.3.0
|
|
275
|
-
*
|
|
276
|
-
* @benchmark
|
|
277
|
-
* typeof function(){} == 'function': 1e+7: 12.811ms
|
|
278
|
-
* typeof function(){} === 'function': 1e+6: 5.016ms
|
|
279
|
-
* (function(){}) instanceof Function: 1e+6: 21.784ms
|
|
280
|
-
* _.isFunction: 1e+6: 71.169ms
|
|
281
|
-
*
|
|
282
|
-
* Instance.isFunction: 1e+6: 5.132ms - typeof x == 'function'
|
|
283
|
-
* Instance.isFunction: 1e+6: 5.236ms - typeof x === 'function'
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
// timeInLoop('typeof function(){} == \'function\'', 1e7, () => { typeof (function(){}) == 'function' })
|
|
287
|
-
|
|
288
|
-
// timeInLoop('typeof function(){} === \'function\'', 1e6, () => { typeof (function(){}) === 'function' })
|
|
289
|
-
|
|
290
|
-
// timeInLoop('(function(){}) instanceof Function', 1e6, () => { (function(){}) instanceof Function })
|
|
291
|
-
|
|
292
|
-
// timeInLoop('_.isFunction', 1e6, () => _.isFunction(function(){}))
|
|
293
|
-
|
|
294
|
-
// timeInLoop('Instance.isFunction', 1e6, () => Instance.isFunction(function(){}))
|
|
295
|
-
|
|
296
|
-
/*
|
|
297
|
-
* @name Instance.isReadable
|
|
298
|
-
*
|
|
299
|
-
* @node_version 14.3.0
|
|
300
|
-
*
|
|
301
|
-
* @benchmark
|
|
302
|
-
* typeof ({ read(){} }).read == 'function': 1e+7: 14.234ms
|
|
303
|
-
* typeof ({ read(){} }).read === 'function': 1e+7: 14.125ms
|
|
304
|
-
*
|
|
305
|
-
* Instance.isReadable({ read(){} }): 1e+7: 14.885ms - typeof x.read == 'function'
|
|
306
|
-
* Instance.isReadable({ read(){} }): 1e+7: 14.966ms - typeof x.read === 'function'
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
// timeInLoop('typeof ({ read(){} }).read == \'function\'', 1e7, () => { typeof ({ read(){} }).read == 'function' })
|
|
310
|
-
|
|
311
|
-
// timeInLoop('typeof ({ read(){} }).read === \'function\'', 1e7, () => { typeof ({ read(){} }).read == 'function' })
|
|
312
|
-
|
|
313
|
-
// timeInLoop('Instance.isReadable({ read(){} })', 1e7, () => Instance.isReadable({ read(){} }))
|
|
314
|
-
|
|
315
|
-
/*
|
|
316
|
-
* @name Instance.isWritable
|
|
317
|
-
*
|
|
318
|
-
* @node_version 14.3.0
|
|
319
|
-
*
|
|
320
|
-
* @benchmark
|
|
321
|
-
* typeof ({ write(){} }).write == 'function': 1e+7: 14.096ms
|
|
322
|
-
* typeof ({ write(){} }).write === 'function': 1e+7: 14.126ms
|
|
323
|
-
*
|
|
324
|
-
* Instance.isWritable({ write(){} }): 1e+7: 14.899ms - typeof x.write == 'function'
|
|
325
|
-
* Instance.isWritable({ write(){} }): 1e+7: 15.029ms - typeof x.write === 'function'
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
// timeInLoop('typeof ({ write(){} }).write == \'function\'', 1e7, () => { typeof ({ write(){} }).write == 'function' })
|
|
329
|
-
|
|
330
|
-
// timeInLoop('typeof ({ write(){} }).write === \'function\'', 1e7, () => { typeof ({ write(){} }).write == 'function' })
|
|
331
|
-
|
|
332
|
-
// timeInLoop('Instance.isWritable({ write(){} })', 1e7, () => Instance.isWritable({ write(){} }))
|
|
333
|
-
|
|
334
|
-
/*
|
|
335
|
-
* @name Instance.isPromise
|
|
336
|
-
*
|
|
337
|
-
* @node_version 14.3.0
|
|
338
|
-
*
|
|
339
|
-
* @benchmark
|
|
340
|
-
* Promise.resolve() instnaceof Promise: 1e+6: 18.719ms
|
|
341
|
-
* typeof Promise.resolve().then == 'function': 1e+6: 18.365ms
|
|
342
|
-
* typeof Promise.resolve().then === 'function': 1e+6: 19.201ms
|
|
343
|
-
*
|
|
344
|
-
* Instance.isPromise(Promise.resolve()): 1e+6: 19.341ms - typeof x.then == 'function'
|
|
345
|
-
* Instance.isPromise(Promise.resolve()): 1e+6: 19.974ms - typeof x.then === 'function'
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
// timeInLoop('Promise.resolve() instnaceof Promise', 1e6, () => { Promise.resolve() instanceof Promise })
|
|
349
|
-
|
|
350
|
-
// timeInLoop('typeof Promise.resolve().then == \'function\'', 1e6, () => { typeof Promise.resolve().then == 'function' })
|
|
351
|
-
|
|
352
|
-
// timeInLoop('typeof Promise.resolve().then === \'function\'', 1e6, () => { typeof Promise.resolve().then === 'function' })
|
|
353
|
-
|
|
354
|
-
// timeInLoop('Instance.isPromise(Promise.resolve())', 1e6, () => Instance.isPromise(Promise.resolve()))
|
|
355
|
-
|
|
356
|
-
/*
|
|
357
|
-
* @name Instance.isTypedArray
|
|
358
|
-
*
|
|
359
|
-
* @node_version 14.3.0
|
|
360
|
-
*
|
|
361
|
-
* @benchmark
|
|
362
|
-
* Instance.isTypedArrayCandidate0(new Uint8Array): 1e+6: 91.477ms
|
|
363
|
-
* Instance.isTypedArrayCandidate0(new Uint8Array): 1e+6: 51.18ms
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
// timeInLoop('Instance.isTypedArrayCandidate0(new Uint8Array)', 1e6, () => Instance.isTypedArrayCandidate0(new Uint8Array))
|
|
367
|
-
|
|
368
|
-
// timeInLoop('Instance.isTypedArrayCandidate0(new Uint8Array)', 1e6, () => Instance.isTypedArrayCandidate1(new Uint8Array))
|
|
369
|
-
|
|
370
|
-
/*
|
|
371
|
-
* @name
|
|
372
|
-
*
|
|
373
|
-
* @node_version 14.3.0
|
|
374
|
-
*
|
|
375
|
-
* @benchmark
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
// timeInLoop('', 1e6, () => {})
|