rubico 2.8.0 → 2.8.2
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/LICENSE +5 -17
- package/README.md +1 -1
- package/_internal/curryArity.js +21 -1
- package/_internal/funcApply2.js +18 -0
- package/curry.js +38 -11
- package/dist/Transducer.es.js +5 -4
- package/dist/Transducer.es.min.js +5 -4
- package/dist/Transducer.js +5 -4
- package/dist/Transducer.min.js +5 -4
- package/dist/Transducer.mjs +5 -4
- package/dist/__.es.js +5 -4
- package/dist/__.es.min.js +5 -4
- package/dist/__.js +5 -4
- package/dist/__.min.js +5 -4
- package/dist/__.mjs +5 -4
- package/dist/all.es.js +5 -4
- package/dist/all.es.min.js +5 -4
- package/dist/all.js +5 -4
- package/dist/all.min.js +5 -4
- package/dist/all.mjs +5 -4
- package/dist/always.es.js +5 -4
- package/dist/always.es.min.js +5 -4
- package/dist/always.js +5 -4
- package/dist/always.min.js +5 -4
- package/dist/always.mjs +5 -4
- package/dist/and.es.js +5 -4
- package/dist/and.es.min.js +5 -4
- package/dist/and.js +5 -4
- package/dist/and.min.js +5 -4
- package/dist/and.mjs +5 -4
- package/dist/assign.es.js +5 -4
- package/dist/assign.es.min.js +5 -4
- package/dist/assign.js +5 -4
- package/dist/assign.min.js +5 -4
- package/dist/assign.mjs +5 -4
- package/dist/compose.es.js +5 -4
- package/dist/compose.es.min.js +5 -4
- package/dist/compose.js +5 -4
- package/dist/compose.min.js +5 -4
- package/dist/compose.mjs +5 -4
- package/dist/curry.es.js +136 -6
- package/dist/curry.es.min.js +6 -5
- package/dist/curry.js +136 -6
- package/dist/curry.min.js +6 -5
- package/dist/curry.mjs +136 -6
- package/dist/eq.es.js +5 -4
- package/dist/eq.es.min.js +5 -4
- package/dist/eq.js +5 -4
- package/dist/eq.min.js +5 -4
- package/dist/eq.mjs +5 -4
- package/dist/every.es.js +5 -4
- package/dist/every.es.min.js +5 -4
- package/dist/every.js +5 -4
- package/dist/every.min.js +5 -4
- package/dist/every.mjs +5 -4
- package/dist/filter.es.js +5 -4
- package/dist/filter.es.min.js +5 -4
- package/dist/filter.js +5 -4
- package/dist/filter.min.js +5 -4
- package/dist/filter.mjs +5 -4
- package/dist/flatMap.es.js +5 -4
- package/dist/flatMap.es.min.js +5 -4
- package/dist/flatMap.js +5 -4
- package/dist/flatMap.min.js +5 -4
- package/dist/flatMap.mjs +5 -4
- package/dist/forEach.es.js +5 -4
- package/dist/forEach.es.min.js +5 -4
- package/dist/forEach.js +5 -4
- package/dist/forEach.min.js +5 -4
- package/dist/forEach.mjs +5 -4
- package/dist/get.es.js +5 -4
- package/dist/get.es.min.js +5 -4
- package/dist/get.js +5 -4
- package/dist/get.min.js +5 -4
- package/dist/get.mjs +5 -4
- package/dist/gt.es.js +5 -4
- package/dist/gt.es.min.js +5 -4
- package/dist/gt.js +5 -4
- package/dist/gt.min.js +5 -4
- package/dist/gt.mjs +5 -4
- package/dist/gte.es.js +5 -4
- package/dist/gte.es.min.js +5 -4
- package/dist/gte.js +5 -4
- package/dist/gte.min.js +5 -4
- package/dist/gte.mjs +5 -4
- package/dist/lt.es.js +5 -4
- package/dist/lt.es.min.js +5 -4
- package/dist/lt.js +5 -4
- package/dist/lt.min.js +5 -4
- package/dist/lt.mjs +5 -4
- package/dist/lte.es.js +5 -4
- package/dist/lte.es.min.js +5 -4
- package/dist/lte.js +5 -4
- package/dist/lte.min.js +5 -4
- package/dist/lte.mjs +5 -4
- package/dist/map.es.js +45 -5
- package/dist/map.es.min.js +6 -5
- package/dist/map.js +45 -5
- package/dist/map.min.js +6 -5
- package/dist/map.mjs +45 -5
- package/dist/not.es.js +5 -4
- package/dist/not.es.min.js +5 -4
- package/dist/not.js +5 -4
- package/dist/not.min.js +5 -4
- package/dist/not.mjs +5 -4
- package/dist/omit.es.js +5 -4
- package/dist/omit.es.min.js +5 -4
- package/dist/omit.js +5 -4
- package/dist/omit.min.js +5 -4
- package/dist/omit.mjs +5 -4
- package/dist/or.es.js +5 -4
- package/dist/or.es.min.js +5 -4
- package/dist/or.js +5 -4
- package/dist/or.min.js +5 -4
- package/dist/or.mjs +5 -4
- package/dist/pick.es.js +5 -4
- package/dist/pick.es.min.js +5 -4
- package/dist/pick.js +5 -4
- package/dist/pick.min.js +5 -4
- package/dist/pick.mjs +5 -4
- package/dist/pipe.es.js +5 -4
- package/dist/pipe.es.min.js +5 -4
- package/dist/pipe.js +5 -4
- package/dist/pipe.min.js +5 -4
- package/dist/pipe.mjs +5 -4
- package/dist/reduce.es.js +5 -4
- package/dist/reduce.es.min.js +5 -4
- package/dist/reduce.js +5 -4
- package/dist/reduce.min.js +5 -4
- package/dist/reduce.mjs +5 -4
- package/dist/rubico.es.js +51 -9
- package/dist/rubico.es.min.js +6 -5
- package/dist/rubico.global.js +51 -9
- package/dist/rubico.global.min.js +6 -5
- package/dist/rubico.js +51 -9
- package/dist/rubico.min.js +6 -5
- package/dist/rubico.mjs +51 -9
- package/dist/set.es.js +5 -4
- package/dist/set.es.min.js +5 -4
- package/dist/set.js +5 -4
- package/dist/set.min.js +5 -4
- package/dist/set.mjs +5 -4
- package/dist/some.es.js +5 -4
- package/dist/some.es.min.js +5 -4
- package/dist/some.js +5 -4
- package/dist/some.min.js +5 -4
- package/dist/some.mjs +5 -4
- package/dist/switchCase.es.js +5 -4
- package/dist/switchCase.es.min.js +5 -4
- package/dist/switchCase.js +5 -4
- package/dist/switchCase.min.js +5 -4
- package/dist/switchCase.mjs +5 -4
- package/dist/tap.es.js +5 -4
- package/dist/tap.es.min.js +5 -4
- package/dist/tap.js +5 -4
- package/dist/tap.min.js +5 -4
- package/dist/tap.mjs +5 -4
- package/dist/thunkify.es.js +45 -20
- package/dist/thunkify.es.min.js +6 -5
- package/dist/thunkify.js +45 -20
- package/dist/thunkify.min.js +6 -5
- package/dist/thunkify.mjs +45 -20
- package/dist/transform.es.js +5 -4
- package/dist/transform.es.min.js +5 -4
- package/dist/transform.js +5 -4
- package/dist/transform.min.js +5 -4
- package/dist/transform.mjs +5 -4
- package/dist/tryCatch.es.js +5 -4
- package/dist/tryCatch.es.min.js +5 -4
- package/dist/tryCatch.js +5 -4
- package/dist/tryCatch.min.js +5 -4
- package/dist/tryCatch.mjs +5 -4
- package/dist/x/append.es.js +5 -4
- package/dist/x/append.es.min.js +5 -4
- package/dist/x/append.js +5 -4
- package/dist/x/append.min.js +5 -4
- package/dist/x/append.mjs +5 -4
- package/dist/x/callProp.es.js +5 -4
- package/dist/x/callProp.es.min.js +5 -4
- package/dist/x/callProp.js +5 -4
- package/dist/x/callProp.min.js +5 -4
- package/dist/x/callProp.mjs +5 -4
- package/dist/x/defaultsDeep.es.js +5 -4
- package/dist/x/defaultsDeep.es.min.js +5 -4
- package/dist/x/defaultsDeep.js +5 -4
- package/dist/x/defaultsDeep.min.js +5 -4
- package/dist/x/defaultsDeep.mjs +5 -4
- package/dist/x/differenceWith.es.js +5 -4
- package/dist/x/differenceWith.es.min.js +5 -4
- package/dist/x/differenceWith.js +5 -4
- package/dist/x/differenceWith.min.js +5 -4
- package/dist/x/differenceWith.mjs +5 -4
- package/dist/x/filterOut.es.js +5 -4
- package/dist/x/filterOut.es.min.js +5 -4
- package/dist/x/filterOut.js +5 -4
- package/dist/x/filterOut.min.js +5 -4
- package/dist/x/filterOut.mjs +5 -4
- package/dist/x/find.es.js +5 -4
- package/dist/x/find.es.min.js +5 -4
- package/dist/x/find.js +5 -4
- package/dist/x/find.min.js +5 -4
- package/dist/x/find.mjs +5 -4
- package/dist/x/findIndex.es.js +5 -4
- package/dist/x/findIndex.es.min.js +5 -4
- package/dist/x/findIndex.js +5 -4
- package/dist/x/findIndex.min.js +5 -4
- package/dist/x/findIndex.mjs +5 -4
- package/dist/x/first.es.js +5 -4
- package/dist/x/first.es.min.js +5 -4
- package/dist/x/first.js +5 -4
- package/dist/x/first.min.js +5 -4
- package/dist/x/first.mjs +5 -4
- package/dist/x/flatten.es.js +5 -4
- package/dist/x/flatten.es.min.js +5 -4
- package/dist/x/flatten.js +5 -4
- package/dist/x/flatten.min.js +5 -4
- package/dist/x/flatten.mjs +5 -4
- package/dist/x/groupBy.es.js +5 -4
- package/dist/x/groupBy.es.min.js +5 -4
- package/dist/x/groupBy.js +5 -4
- package/dist/x/groupBy.min.js +5 -4
- package/dist/x/groupBy.mjs +5 -4
- package/dist/x/has.es.js +5 -4
- package/dist/x/has.es.min.js +5 -4
- package/dist/x/has.js +5 -4
- package/dist/x/has.min.js +5 -4
- package/dist/x/has.mjs +5 -4
- package/dist/x/identity.es.js +5 -4
- package/dist/x/identity.es.min.js +5 -4
- package/dist/x/identity.js +5 -4
- package/dist/x/identity.min.js +5 -4
- package/dist/x/identity.mjs +5 -4
- package/dist/x/includes.es.js +5 -4
- package/dist/x/includes.es.min.js +5 -4
- package/dist/x/includes.js +5 -4
- package/dist/x/includes.min.js +5 -4
- package/dist/x/includes.mjs +5 -4
- package/dist/x/isDeepEqual.es.js +5 -4
- package/dist/x/isDeepEqual.es.min.js +5 -4
- package/dist/x/isDeepEqual.js +5 -4
- package/dist/x/isDeepEqual.min.js +5 -4
- package/dist/x/isDeepEqual.mjs +5 -4
- package/dist/x/isEmpty.es.js +5 -4
- package/dist/x/isEmpty.es.min.js +5 -4
- package/dist/x/isEmpty.js +5 -4
- package/dist/x/isEmpty.min.js +5 -4
- package/dist/x/isEmpty.mjs +5 -4
- package/dist/x/isEqual.es.js +5 -4
- package/dist/x/isEqual.es.min.js +5 -4
- package/dist/x/isEqual.js +5 -4
- package/dist/x/isEqual.min.js +5 -4
- package/dist/x/isEqual.mjs +5 -4
- package/dist/x/isFunction.es.js +5 -4
- package/dist/x/isFunction.es.min.js +5 -4
- package/dist/x/isFunction.js +5 -4
- package/dist/x/isFunction.min.js +5 -4
- package/dist/x/isFunction.mjs +5 -4
- package/dist/x/isIn.es.js +5 -4
- package/dist/x/isIn.es.min.js +5 -4
- package/dist/x/isIn.js +5 -4
- package/dist/x/isIn.min.js +5 -4
- package/dist/x/isIn.mjs +5 -4
- package/dist/x/isObject.es.js +5 -4
- package/dist/x/isObject.es.min.js +5 -4
- package/dist/x/isObject.js +5 -4
- package/dist/x/isObject.min.js +5 -4
- package/dist/x/isObject.mjs +5 -4
- package/dist/x/isString.es.js +5 -4
- package/dist/x/isString.es.min.js +5 -4
- package/dist/x/isString.js +5 -4
- package/dist/x/isString.min.js +5 -4
- package/dist/x/isString.mjs +5 -4
- package/dist/x/keys.es.js +5 -4
- package/dist/x/keys.es.min.js +5 -4
- package/dist/x/keys.js +5 -4
- package/dist/x/keys.min.js +5 -4
- package/dist/x/keys.mjs +5 -4
- package/dist/x/last.es.js +5 -4
- package/dist/x/last.es.min.js +5 -4
- package/dist/x/last.js +5 -4
- package/dist/x/last.min.js +5 -4
- package/dist/x/last.mjs +5 -4
- package/dist/x/maxBy.es.js +5 -4
- package/dist/x/maxBy.es.min.js +5 -4
- package/dist/x/maxBy.js +5 -4
- package/dist/x/maxBy.min.js +5 -4
- package/dist/x/maxBy.mjs +5 -4
- package/dist/x/noop.es.js +5 -4
- package/dist/x/noop.es.min.js +5 -4
- package/dist/x/noop.js +5 -4
- package/dist/x/noop.min.js +5 -4
- package/dist/x/noop.mjs +5 -4
- package/dist/x/pluck.es.js +45 -5
- package/dist/x/pluck.es.min.js +6 -5
- package/dist/x/pluck.js +45 -5
- package/dist/x/pluck.min.js +6 -5
- package/dist/x/pluck.mjs +45 -5
- package/dist/x/prepend.es.js +5 -4
- package/dist/x/prepend.es.min.js +5 -4
- package/dist/x/prepend.js +5 -4
- package/dist/x/prepend.min.js +5 -4
- package/dist/x/prepend.mjs +5 -4
- package/dist/x/size.es.js +5 -4
- package/dist/x/size.es.min.js +5 -4
- package/dist/x/size.js +5 -4
- package/dist/x/size.min.js +5 -4
- package/dist/x/size.mjs +5 -4
- package/dist/x/trace.es.js +5 -4
- package/dist/x/trace.es.min.js +5 -4
- package/dist/x/trace.js +5 -4
- package/dist/x/trace.min.js +5 -4
- package/dist/x/trace.mjs +5 -4
- package/dist/x/unionWith.es.js +5 -4
- package/dist/x/unionWith.es.min.js +5 -4
- package/dist/x/unionWith.js +5 -4
- package/dist/x/unionWith.min.js +5 -4
- package/dist/x/unionWith.mjs +5 -4
- package/dist/x/uniq.es.js +5 -4
- package/dist/x/uniq.es.min.js +5 -4
- package/dist/x/uniq.js +5 -4
- package/dist/x/uniq.min.js +5 -4
- package/dist/x/uniq.mjs +5 -4
- package/dist/x/unless.es.js +5 -4
- package/dist/x/unless.es.min.js +5 -4
- package/dist/x/unless.js +5 -4
- package/dist/x/unless.min.js +5 -4
- package/dist/x/unless.mjs +5 -4
- package/dist/x/values.es.js +5 -4
- package/dist/x/values.es.min.js +5 -4
- package/dist/x/values.js +5 -4
- package/dist/x/values.min.js +5 -4
- package/dist/x/values.mjs +5 -4
- package/dist/x/when.es.js +5 -4
- package/dist/x/when.es.min.js +5 -4
- package/dist/x/when.js +5 -4
- package/dist/x/when.min.js +5 -4
- package/dist/x/when.mjs +5 -4
- package/es.js +51 -9
- package/index.js +51 -9
- package/package.json +1 -1
- package/thunkify.js +66 -6
package/es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* https://
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Rubico v2.8.2
|
|
3
|
+
* https://rubico.land/
|
|
4
|
+
*
|
|
5
|
+
* © Richard Yufei Tong, King of Software
|
|
6
|
+
* Rubico may be freely distributed under the CFOSS license.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
const isArray = Array.isArray
|
|
@@ -1062,6 +1063,8 @@ const objectMapPool = function (o, concurrency, f) {
|
|
|
1062
1063
|
return result
|
|
1063
1064
|
}
|
|
1064
1065
|
|
|
1066
|
+
const funcApply2 = (func, context, args) => func.apply(context, args)
|
|
1067
|
+
|
|
1065
1068
|
const _curryArity = (arity, func, context, args) => function curried(...curriedArgs) {
|
|
1066
1069
|
const argsLength = args.length,
|
|
1067
1070
|
curriedArgsLength = curriedArgs.length,
|
|
@@ -1081,7 +1084,13 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1081
1084
|
} else {
|
|
1082
1085
|
nextArgs.push(arg)
|
|
1083
1086
|
}
|
|
1087
|
+
|
|
1084
1088
|
if (nextArgs.length == arity) {
|
|
1089
|
+
if (areAnyValuesPromises(nextArgs)) {
|
|
1090
|
+
return numCurriedPlaceholders == 0
|
|
1091
|
+
? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
|
|
1092
|
+
: promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1093
|
+
}
|
|
1085
1094
|
return numCurriedPlaceholders == 0
|
|
1086
1095
|
? func.apply(context, nextArgs)
|
|
1087
1096
|
: curryArity(arity, func, context, nextArgs)
|
|
@@ -1094,13 +1103,22 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1094
1103
|
numCurriedPlaceholders += 1
|
|
1095
1104
|
}
|
|
1096
1105
|
nextArgs.push(curriedArg)
|
|
1106
|
+
|
|
1097
1107
|
if (nextArgs.length == arity) {
|
|
1108
|
+
if (areAnyValuesPromises(nextArgs)) {
|
|
1109
|
+
return numCurriedPlaceholders == 0
|
|
1110
|
+
? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
|
|
1111
|
+
: promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1112
|
+
}
|
|
1098
1113
|
return numCurriedPlaceholders == 0
|
|
1099
1114
|
? func.apply(context, nextArgs)
|
|
1100
1115
|
: curryArity(arity, func, context, nextArgs)
|
|
1101
1116
|
}
|
|
1102
1117
|
}
|
|
1103
|
-
|
|
1118
|
+
|
|
1119
|
+
return areAnyValuesPromises(nextArgs)
|
|
1120
|
+
? promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1121
|
+
: curryArity(arity, func, context, nextArgs)
|
|
1104
1122
|
}
|
|
1105
1123
|
|
|
1106
1124
|
const curryArity = function (arity, func, context, args) {
|
|
@@ -3278,20 +3296,44 @@ const omit = function (arg0, arg1) {
|
|
|
3278
3296
|
return _omit(arg0, arg1)
|
|
3279
3297
|
}
|
|
3280
3298
|
|
|
3281
|
-
|
|
3299
|
+
function _thunkifyArgs(func, context, args) {
|
|
3300
|
+
return function thunk() {
|
|
3301
|
+
return func.apply(context, args)
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
const thunkify = function thunkify(func, ...args) {
|
|
3282
3306
|
if (areAnyValuesPromises(args)) {
|
|
3283
|
-
return promiseAll(args).then(
|
|
3307
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
|
|
3284
3308
|
}
|
|
3285
|
-
return func
|
|
3309
|
+
return _thunkifyArgs(func, this, args)
|
|
3286
3310
|
}
|
|
3287
3311
|
|
|
3288
|
-
|
|
3312
|
+
thunkify.call = function thunkifyCall(func, context, ...args) {
|
|
3313
|
+
if (areAnyValuesPromises(args)) {
|
|
3314
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
|
|
3315
|
+
}
|
|
3316
|
+
return _thunkifyArgs(func, context, args)
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
const curry = (func, ...args) => {
|
|
3320
|
+
if (areAnyValuesPromises(args)) {
|
|
3321
|
+
return promiseAll(args).then(curry4(curryArity, func.length, func, this, __))
|
|
3322
|
+
}
|
|
3323
|
+
return curryArity(func.length, func, this, args)
|
|
3324
|
+
}
|
|
3289
3325
|
|
|
3290
3326
|
curry.arity = function curryArity_(arity, func, ...args) {
|
|
3327
|
+
if (areAnyValuesPromises(args)) {
|
|
3328
|
+
return promiseAll(args).then(curry4(curryArity, arity, func, this, __))
|
|
3329
|
+
}
|
|
3291
3330
|
return curryArity(arity, func, this, args)
|
|
3292
3331
|
}
|
|
3293
3332
|
|
|
3294
3333
|
curry.call = function call(func, context, ...args) {
|
|
3334
|
+
if (areAnyValuesPromises(args)) {
|
|
3335
|
+
return promiseAll(args).then(curry4(curryArity, func.length, func, context, __))
|
|
3336
|
+
}
|
|
3295
3337
|
return curryArity(func.length, func, context, args)
|
|
3296
3338
|
}
|
|
3297
3339
|
|
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* https://
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Rubico v2.8.2
|
|
3
|
+
* https://rubico.land/
|
|
4
|
+
*
|
|
5
|
+
* © Richard Yufei Tong, King of Software
|
|
6
|
+
* Rubico may be freely distributed under the CFOSS license.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
(function (root, rubico) {
|
|
@@ -1068,6 +1069,8 @@ const objectMapPool = function (o, concurrency, f) {
|
|
|
1068
1069
|
return result
|
|
1069
1070
|
}
|
|
1070
1071
|
|
|
1072
|
+
const funcApply2 = (func, context, args) => func.apply(context, args)
|
|
1073
|
+
|
|
1071
1074
|
const _curryArity = (arity, func, context, args) => function curried(...curriedArgs) {
|
|
1072
1075
|
const argsLength = args.length,
|
|
1073
1076
|
curriedArgsLength = curriedArgs.length,
|
|
@@ -1087,7 +1090,13 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1087
1090
|
} else {
|
|
1088
1091
|
nextArgs.push(arg)
|
|
1089
1092
|
}
|
|
1093
|
+
|
|
1090
1094
|
if (nextArgs.length == arity) {
|
|
1095
|
+
if (areAnyValuesPromises(nextArgs)) {
|
|
1096
|
+
return numCurriedPlaceholders == 0
|
|
1097
|
+
? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
|
|
1098
|
+
: promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1099
|
+
}
|
|
1091
1100
|
return numCurriedPlaceholders == 0
|
|
1092
1101
|
? func.apply(context, nextArgs)
|
|
1093
1102
|
: curryArity(arity, func, context, nextArgs)
|
|
@@ -1100,13 +1109,22 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1100
1109
|
numCurriedPlaceholders += 1
|
|
1101
1110
|
}
|
|
1102
1111
|
nextArgs.push(curriedArg)
|
|
1112
|
+
|
|
1103
1113
|
if (nextArgs.length == arity) {
|
|
1114
|
+
if (areAnyValuesPromises(nextArgs)) {
|
|
1115
|
+
return numCurriedPlaceholders == 0
|
|
1116
|
+
? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
|
|
1117
|
+
: promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1118
|
+
}
|
|
1104
1119
|
return numCurriedPlaceholders == 0
|
|
1105
1120
|
? func.apply(context, nextArgs)
|
|
1106
1121
|
: curryArity(arity, func, context, nextArgs)
|
|
1107
1122
|
}
|
|
1108
1123
|
}
|
|
1109
|
-
|
|
1124
|
+
|
|
1125
|
+
return areAnyValuesPromises(nextArgs)
|
|
1126
|
+
? promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
|
|
1127
|
+
: curryArity(arity, func, context, nextArgs)
|
|
1110
1128
|
}
|
|
1111
1129
|
|
|
1112
1130
|
const curryArity = function (arity, func, context, args) {
|
|
@@ -3284,20 +3302,44 @@ const omit = function (arg0, arg1) {
|
|
|
3284
3302
|
return _omit(arg0, arg1)
|
|
3285
3303
|
}
|
|
3286
3304
|
|
|
3287
|
-
|
|
3305
|
+
function _thunkifyArgs(func, context, args) {
|
|
3306
|
+
return function thunk() {
|
|
3307
|
+
return func.apply(context, args)
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3311
|
+
const thunkify = function thunkify(func, ...args) {
|
|
3288
3312
|
if (areAnyValuesPromises(args)) {
|
|
3289
|
-
return promiseAll(args).then(
|
|
3313
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
|
|
3290
3314
|
}
|
|
3291
|
-
return func
|
|
3315
|
+
return _thunkifyArgs(func, this, args)
|
|
3292
3316
|
}
|
|
3293
3317
|
|
|
3294
|
-
|
|
3318
|
+
thunkify.call = function thunkifyCall(func, context, ...args) {
|
|
3319
|
+
if (areAnyValuesPromises(args)) {
|
|
3320
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
|
|
3321
|
+
}
|
|
3322
|
+
return _thunkifyArgs(func, context, args)
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
const curry = (func, ...args) => {
|
|
3326
|
+
if (areAnyValuesPromises(args)) {
|
|
3327
|
+
return promiseAll(args).then(curry4(curryArity, func.length, func, this, __))
|
|
3328
|
+
}
|
|
3329
|
+
return curryArity(func.length, func, this, args)
|
|
3330
|
+
}
|
|
3295
3331
|
|
|
3296
3332
|
curry.arity = function curryArity_(arity, func, ...args) {
|
|
3333
|
+
if (areAnyValuesPromises(args)) {
|
|
3334
|
+
return promiseAll(args).then(curry4(curryArity, arity, func, this, __))
|
|
3335
|
+
}
|
|
3297
3336
|
return curryArity(arity, func, this, args)
|
|
3298
3337
|
}
|
|
3299
3338
|
|
|
3300
3339
|
curry.call = function call(func, context, ...args) {
|
|
3340
|
+
if (areAnyValuesPromises(args)) {
|
|
3341
|
+
return promiseAll(args).then(curry4(curryArity, func.length, func, context, __))
|
|
3342
|
+
}
|
|
3301
3343
|
return curryArity(func.length, func, context, args)
|
|
3302
3344
|
}
|
|
3303
3345
|
|
package/package.json
CHANGED
package/thunkify.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
const areAnyValuesPromises = require('./_internal/areAnyValuesPromises')
|
|
2
2
|
const promiseAll = require('./_internal/promiseAll')
|
|
3
|
-
const
|
|
3
|
+
const curry3 = require('./_internal/curry3')
|
|
4
4
|
const __ = require('./_internal/placeholder')
|
|
5
|
-
const
|
|
5
|
+
const funcApply2 = require('./_internal/funcApply2')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name _thunkifyArgs
|
|
9
|
+
*
|
|
10
|
+
* @synopsis
|
|
11
|
+
* ```coffeescript [specscript]
|
|
12
|
+
* _thunkifyArgs(func function, context object, args Array) -> thunk
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
function _thunkifyArgs(func, context, args) {
|
|
16
|
+
return function thunk() {
|
|
17
|
+
return func.apply(context, args)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
6
20
|
|
|
7
21
|
/**
|
|
8
22
|
* @name thunkify
|
|
@@ -15,7 +29,7 @@ const funcApply = require('./_internal/funcApply')
|
|
|
15
29
|
* ```
|
|
16
30
|
*
|
|
17
31
|
* @description
|
|
18
|
-
*
|
|
32
|
+
* Creates a thunk from a function and arguments. A thunk takes no arguments, and when called, executes the other function with the arguments. The other function is said to be "thunkified".
|
|
19
33
|
*
|
|
20
34
|
* ```javascript [playground]
|
|
21
35
|
* const add = (a, b) => a + b
|
|
@@ -27,17 +41,63 @@ const funcApply = require('./_internal/funcApply')
|
|
|
27
41
|
*
|
|
28
42
|
* See also:
|
|
29
43
|
* * [eq](/docs/eq)
|
|
44
|
+
* * [thunkify.call](/docs/thunkify.call)
|
|
45
|
+
* * [always](/docs/always)
|
|
46
|
+
* * [curry](/docs/curry)
|
|
47
|
+
* * [__](/docs/__)
|
|
48
|
+
* * [Transducer.map](/docs/Transducer.map)
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
const thunkify = function thunkify(func, ...args) {
|
|
52
|
+
if (areAnyValuesPromises(args)) {
|
|
53
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
|
|
54
|
+
}
|
|
55
|
+
return _thunkifyArgs(func, this, args)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @name thunkify.call
|
|
60
|
+
*
|
|
61
|
+
* @synopsis
|
|
62
|
+
* ```coffeescript [specscript]
|
|
63
|
+
* args Array<any>
|
|
64
|
+
*
|
|
65
|
+
* thunkify.call(func function, context object, ...args) -> thunk ()=>func(...args)
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Creates a thunk that calls a function with the specified context and arguments.
|
|
69
|
+
*
|
|
70
|
+
* ```javascript [playground]
|
|
71
|
+
* class Point {
|
|
72
|
+
* constructor(x, y) {
|
|
73
|
+
* this.x = x
|
|
74
|
+
* this.y = y
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* toString() {
|
|
78
|
+
* return `(${this.x}, ${this.y})`
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* const thunk = thunkify.call(toString, point)
|
|
83
|
+
*
|
|
84
|
+
* console.log(thunk())
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* See also:
|
|
88
|
+
* * [eq](/docs/eq)
|
|
89
|
+
* * [thunkify](/docs/thunkify)
|
|
30
90
|
* * [always](/docs/always)
|
|
31
91
|
* * [curry](/docs/curry)
|
|
32
92
|
* * [__](/docs/__)
|
|
33
93
|
* * [Transducer.map](/docs/Transducer.map)
|
|
34
94
|
*
|
|
35
95
|
*/
|
|
36
|
-
|
|
96
|
+
thunkify.call = function thunkifyCall(func, context, ...args) {
|
|
37
97
|
if (areAnyValuesPromises(args)) {
|
|
38
|
-
return promiseAll(args).then(
|
|
98
|
+
return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
|
|
39
99
|
}
|
|
40
|
-
return func
|
|
100
|
+
return _thunkifyArgs(func, context, args)
|
|
41
101
|
}
|
|
42
102
|
|
|
43
103
|
module.exports = thunkify
|