rubico 2.11.0 → 2.13.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 +16 -20
- package/Transducer.js +87 -72
- package/__.js +3 -3
- package/_internal/functionArrayAllSeries.js +4 -3
- package/_internal/functionObjectAllSeries.js +65 -0
- package/_internal/genericTransform.js +0 -1
- package/all.js +36 -16
- package/always.js +4 -4
- package/and.js +34 -26
- package/assign.js +5 -5
- package/compose.js +7 -6
- package/curry.js +48 -28
- package/dist/Transducer.es.js +1 -1
- package/dist/Transducer.es.min.js +1 -1
- package/dist/Transducer.js +1 -1
- package/dist/Transducer.min.js +1 -1
- package/dist/Transducer.mjs +1 -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 +112 -8
- package/dist/all.es.min.js +2 -2
- package/dist/all.js +112 -8
- package/dist/all.min.js +2 -2
- package/dist/all.mjs +112 -8
- 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 +113 -19
- package/dist/filter.es.min.js +2 -2
- package/dist/filter.js +113 -19
- package/dist/filter.min.js +2 -2
- package/dist/filter.mjs +113 -19
- 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 +168 -79
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +168 -79
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +168 -79
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +168 -79
- 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 +1 -1
- package/dist/tap.es.min.js +1 -1
- package/dist/tap.js +1 -1
- package/dist/tap.min.js +1 -1
- package/dist/tap.mjs +1 -1
- 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 +1 -3
- package/dist/transform.es.min.js +2 -2
- package/dist/transform.js +1 -3
- package/dist/transform.min.js +1 -1
- package/dist/transform.mjs +1 -3
- 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 +113 -19
- package/dist/x/filterOut.es.min.js +2 -2
- package/dist/x/filterOut.js +113 -19
- package/dist/x/filterOut.min.js +2 -2
- package/dist/x/filterOut.mjs +113 -19
- 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 +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +1 -1
- package/dist/x/trace.mjs +1 -1
- 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/eq.js +29 -30
- package/es.js +168 -79
- package/every.js +16 -22
- package/filter.js +41 -78
- package/flatMap.js +16 -16
- package/forEach.js +14 -14
- package/get.js +3 -3
- package/gt.js +18 -25
- package/gte.js +22 -29
- package/index.js +168 -79
- package/lt.js +33 -31
- package/lte.js +24 -31
- package/map.js +43 -46
- package/not.js +12 -17
- package/or.js +34 -26
- package/package.json +1 -1
- package/pipe.js +6 -6
- package/reduce.js +62 -69
- package/some.js +13 -36
- package/switchCase.js +9 -9
- package/tap.js +7 -12
- package/thunkify.js +42 -12
- package/transform.js +62 -61
- package/tryCatch.js +4 -7
- package/_internal/add.js +0 -12
package/and.js
CHANGED
|
@@ -97,37 +97,28 @@ const areAllPredicatesTruthy = function (args, predicates) {
|
|
|
97
97
|
*
|
|
98
98
|
* @synopsis
|
|
99
99
|
* ```coffeescript [specscript]
|
|
100
|
-
*
|
|
101
|
-
* argsOrPromises Array<Promise|any>
|
|
100
|
+
* type Predicate = (...arguments)=>Promise|boolean|any
|
|
102
101
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* predicatesOrValues Array<
|
|
106
|
-
*
|
|
107
|
-
* and(values Array<boolean|any>) -> result boolean
|
|
108
|
-
* and(...argsOrPromises, predicatesOrValues) -> Promise|boolean
|
|
109
|
-
* and(predicatesOrValues)(...args) -> Promise|boolean
|
|
102
|
+
* and(values Array<boolean|any>) -> testResult boolean
|
|
103
|
+
* and(...arguments, predicatesOrValues Array<Predicate|boolean|any>) -> testResult Promise|boolean
|
|
104
|
+
* and(predicatesOrValues Array<Predicate|boolean|any>)(...arguments) -> testResult Promise|boolean
|
|
110
105
|
* ```
|
|
111
106
|
*
|
|
112
107
|
* @description
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* If provided an array of boolean values, `and` returns true if all boolean values are true.
|
|
108
|
+
* Logical operator. Tests an array of predicate functions, promises, or values, returning true if all predicates test true and all values are truthy.
|
|
116
109
|
*
|
|
117
110
|
* ```javascript [playground]
|
|
118
|
-
* const
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* const condition = and([
|
|
123
|
-
* oneIsLessThanThree,
|
|
124
|
-
* twoIsGreaterThanOne,
|
|
125
|
-
* threeIsEqualToThree
|
|
111
|
+
* const isOddAndGreaterThan3 = and([
|
|
112
|
+
* n => n % 2 == 1,
|
|
113
|
+
* n => n > 3,
|
|
126
114
|
* ])
|
|
127
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* console.log(isOddAndGreaterThan3(5))
|
|
117
|
+
* console.log(isOddAndGreaterThan3(3))
|
|
118
|
+
* console.log(isOddAndGreaterThan3(6))
|
|
128
119
|
* ```
|
|
129
120
|
*
|
|
130
|
-
* If
|
|
121
|
+
* If the array contains predicate functions, `and` returns an aggregate predicate function that returns true if all predicate functions test true. If any predicate function is asynchronous, the aggregate predicate function is asynchronous.
|
|
131
122
|
*
|
|
132
123
|
* ```javascript [playground]
|
|
133
124
|
* const isOdd = number => number % 2 == 1
|
|
@@ -141,17 +132,34 @@ const areAllPredicatesTruthy = function (args, predicates) {
|
|
|
141
132
|
* asyncIsLessThan3,
|
|
142
133
|
* ])
|
|
143
134
|
*
|
|
144
|
-
* const
|
|
145
|
-
*
|
|
135
|
+
* const booleanResult = await aggregatePredicate(1)
|
|
136
|
+
*
|
|
137
|
+
* console.log(booleanResult)
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* If the array contains only values, `and` returns a boolean value.
|
|
141
|
+
*
|
|
142
|
+
* ```javascript [playground]
|
|
143
|
+
* const oneIsLessThanThree = 1 < 3
|
|
144
|
+
* const twoIsGreaterThanOne = 2 > 1
|
|
145
|
+
* const threeIsEqualToThree = 3 === 3
|
|
146
|
+
*
|
|
147
|
+
* const booleanResult = and([
|
|
148
|
+
* oneIsLessThanThree,
|
|
149
|
+
* twoIsGreaterThanOne,
|
|
150
|
+
* threeIsEqualToThree
|
|
151
|
+
* ])
|
|
152
|
+
*
|
|
153
|
+
* console.log(booleanResult)
|
|
146
154
|
* ```
|
|
147
155
|
*
|
|
148
|
-
* Any promises
|
|
156
|
+
* Any promises in the array are resolved for their values before further execution.
|
|
149
157
|
*
|
|
150
158
|
* ```javascript [playground]
|
|
151
159
|
* and(Promise.resolve(5), [
|
|
152
160
|
* n => n > 0,
|
|
153
161
|
* n => n < 10,
|
|
154
|
-
* ]).then(console.log)
|
|
162
|
+
* ]).then(console.log)
|
|
155
163
|
* ```
|
|
156
164
|
*
|
|
157
165
|
* See also:
|
package/assign.js
CHANGED
|
@@ -18,10 +18,10 @@ const _assign = function (object, funcs) {
|
|
|
18
18
|
*
|
|
19
19
|
* @synopsis
|
|
20
20
|
* ```coffeescript [specscript]
|
|
21
|
-
* type
|
|
21
|
+
* type Resolver = any=>Promise|any
|
|
22
22
|
*
|
|
23
|
-
* assign(Promise|Object, Object<
|
|
24
|
-
* assign(Object<
|
|
23
|
+
* assign(Promise|Object, Object<Resolver|Promise|any>) -> Promise|Object
|
|
24
|
+
* assign(Object<Resolver|Promise|any>)(Object) -> Promise|Object
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
27
|
* @description
|
|
@@ -56,9 +56,9 @@ const _assign = function (object, funcs) {
|
|
|
56
56
|
* },
|
|
57
57
|
* })
|
|
58
58
|
*
|
|
59
|
-
* const
|
|
59
|
+
* const result = await asyncAssignTotal({ numbers: [1, 2, 3, 4, 5] })
|
|
60
60
|
*
|
|
61
|
-
*
|
|
61
|
+
* console.log(result)
|
|
62
62
|
* ```
|
|
63
63
|
*
|
|
64
64
|
* If the argument object is a promise, it is resolved for its value before further execution for the eager interface only.
|
package/compose.js
CHANGED
|
@@ -10,14 +10,14 @@ const funcConcat = require('./_internal/funcConcat')
|
|
|
10
10
|
*
|
|
11
11
|
* @synopsis
|
|
12
12
|
* ```coffeescript [specscript]
|
|
13
|
-
* type
|
|
14
|
-
* type
|
|
13
|
+
* type Function = (...arguments)=>Promise|any
|
|
14
|
+
* type UnaryFunction = any=>Promise|any
|
|
15
15
|
*
|
|
16
|
-
* funcs [
|
|
16
|
+
* funcs [Function, ...Array<UnaryFunction>]
|
|
17
17
|
*
|
|
18
|
-
* compose(funcs)(...arguments) -> Promise|any
|
|
19
|
-
* compose(...arguments, funcs) -> Promise|any
|
|
20
|
-
* compose(...funcs)(...arguments) -> Promise|any
|
|
18
|
+
* compose(funcs)(...arguments) -> result Promise|any
|
|
19
|
+
* compose(...arguments, funcs) -> result Promise|any
|
|
20
|
+
* compose(...funcs)(...arguments) -> result Promise|any
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* @description
|
|
@@ -30,6 +30,7 @@ const funcConcat = require('./_internal/funcConcat')
|
|
|
30
30
|
* const g = x => x + 3
|
|
31
31
|
*
|
|
32
32
|
* const result = compose(5, [f, g])
|
|
33
|
+
*
|
|
33
34
|
* console.log(result)
|
|
34
35
|
* ```
|
|
35
36
|
*
|
package/curry.js
CHANGED
|
@@ -10,18 +10,15 @@ const curryArity = require('./_internal/curryArity')
|
|
|
10
10
|
* @synopsis
|
|
11
11
|
* ```coffeescript [specscript]
|
|
12
12
|
* __ Symbol(placeholder)
|
|
13
|
+
* argumentsWithPlaceholder Array<__|any>
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* moreArgs ArgsWithPlaceholder
|
|
18
|
-
*
|
|
19
|
-
* curry(func function, ...args) -> curriedFuncOrResult function|any
|
|
20
|
-
* curriedFuncOrResult(...moreArgs) -> anotherCurriedFuncOrResult function|any
|
|
15
|
+
* curry(func function, ...arguments) -> result any
|
|
16
|
+
* curry(func function, ...argumentsWithPlaceholder) -> result any
|
|
17
|
+
* curry(func function, ...argumentsWithPlaceholder) -> curriedFunction function
|
|
21
18
|
* ```
|
|
22
19
|
*
|
|
23
20
|
* @description
|
|
24
|
-
* Enables partial application of a function's arguments in any order.
|
|
21
|
+
* Enables partial application of a function's arguments in any order. The placeholder value [__](/docs/__) specifies an argument to be resolved in the partially applied function.
|
|
25
22
|
*
|
|
26
23
|
* ```javascript [playground]
|
|
27
24
|
* const add = (a, b, c) => a + b + c
|
|
@@ -31,13 +28,12 @@ const curryArity = require('./_internal/curryArity')
|
|
|
31
28
|
* console.log(curry(add, 'a')('b', 'c'))
|
|
32
29
|
* console.log(curry(add, 'a', 'b')('c'))
|
|
33
30
|
* console.log(curry(add)('a')('b')('c'))
|
|
34
|
-
*
|
|
35
31
|
* console.log(curry(add, __, 'b', 'c')('a'))
|
|
36
32
|
* console.log(curry(add, __, __, 'c')('a', 'b'))
|
|
37
33
|
* console.log(curry(add, __, __, 'c')(__, 'b')('a'))
|
|
38
34
|
* ```
|
|
39
35
|
*
|
|
40
|
-
* Any promises
|
|
36
|
+
* Any promises in `arguments` or `argumentsWithPlaceholder` are resolved for their values before further execution.
|
|
41
37
|
*
|
|
42
38
|
* ```javascript [playground]
|
|
43
39
|
* const add = (a, b, c) => a + b + c
|
|
@@ -71,24 +67,29 @@ const curry = (func, ...args) => {
|
|
|
71
67
|
*
|
|
72
68
|
* @synopsis
|
|
73
69
|
* ```coffeescript [specscript]
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* n number
|
|
78
|
-
* args ArgsWithPlaceholder
|
|
79
|
-
* moreArgs ArgsWithPlaceholder
|
|
70
|
+
* __ Symbol(placeholder)
|
|
71
|
+
* argumentsWithPlaceholder Array<__|any>
|
|
80
72
|
*
|
|
81
|
-
* curry.arity(n number, func function, ...
|
|
82
|
-
*
|
|
73
|
+
* curry.arity(n number, func function, ...arguments) -> result any
|
|
74
|
+
* curry.arity(n number, func function, ...argumentsWithPlaceholder) -> result any
|
|
75
|
+
* curry.arity(n number, func function, ...argumentsWithPlaceholder) -> curriedFunction function
|
|
83
76
|
* ```
|
|
84
77
|
*
|
|
85
78
|
* @description
|
|
86
|
-
* [curry](/docs/curry) with specified arity (number of arguments taken by the function)
|
|
79
|
+
* [curry](/docs/curry) with specified arity (number of arguments taken by the function).
|
|
80
|
+
*
|
|
81
|
+
* ```javascript [playground]
|
|
82
|
+
* const add = (a, b, c = 0) => a + b + c
|
|
83
|
+
*
|
|
84
|
+
* console.log(curry.arity(2, add, 1, 2))
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* Any promises in `arguments` or `argumentsWithPlaceholder` are resolved for their values before further execution.
|
|
87
88
|
*
|
|
88
89
|
* ```javascript [playground]
|
|
89
90
|
* const add = (a, b, c = 0) => a + b + c
|
|
90
91
|
*
|
|
91
|
-
* console.log(curry.arity(2, add, 1, 2))
|
|
92
|
+
* console.log(await curry.arity(2, add, Promise.resolve(1), 2))
|
|
92
93
|
* ```
|
|
93
94
|
*
|
|
94
95
|
* See also:
|
|
@@ -113,15 +114,12 @@ curry.arity = function curryArity_(arity, func, ...args) {
|
|
|
113
114
|
*
|
|
114
115
|
* @synopsis
|
|
115
116
|
* ```coffeescript [specscript]
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* n number
|
|
120
|
-
* args ArgsWithPlaceholder
|
|
121
|
-
* moreArgs ArgsWithPlaceholder
|
|
117
|
+
* __ Symbol(placeholder)
|
|
118
|
+
* argumentsWithPlaceholder Array<__|any>
|
|
122
119
|
*
|
|
123
|
-
* curry.call(func function, context object, ...
|
|
124
|
-
*
|
|
120
|
+
* curry.call(func function, context object, ...arguments) -> result any
|
|
121
|
+
* curry.call(func function, context object, ...argumentsWithPlaceholder) -> result any
|
|
122
|
+
* curry.call(func function, context object, ...argumentsWithPlaceholder) -> curriedFunction function
|
|
125
123
|
* ```
|
|
126
124
|
*
|
|
127
125
|
* @description
|
|
@@ -147,6 +145,28 @@ curry.arity = function curryArity_(arity, func, ...args) {
|
|
|
147
145
|
* console.log(curry.call(point.toString, box))
|
|
148
146
|
* ```
|
|
149
147
|
*
|
|
148
|
+
* Any promises in `arguments` are resolved for their values during thunk creation.
|
|
149
|
+
*
|
|
150
|
+
* ```javascript [playground]
|
|
151
|
+
* class Point {
|
|
152
|
+
* constructor(x, y) {
|
|
153
|
+
* this.x = x
|
|
154
|
+
* this.y = y
|
|
155
|
+
* }
|
|
156
|
+
*
|
|
157
|
+
* distanceTo(point) {
|
|
158
|
+
* const x2 = (point.x - this.x) ** 2
|
|
159
|
+
* const y2 = (point.y - this.y) ** 2
|
|
160
|
+
* return (x2 + y2) ** 0.5
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* const point1 = new Point(100, 100)
|
|
165
|
+
* const point2 = new Point(200, 200)
|
|
166
|
+
*
|
|
167
|
+
* console.log(await curry.call(point1.distanceTo, point1, Promise.resolve(point2)))
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
150
170
|
* See also:
|
|
151
171
|
* * [eq](/docs/eq)
|
|
152
172
|
* * [thunkify](/docs/thunkify)
|
package/dist/Transducer.es.js
CHANGED
package/dist/Transducer.js
CHANGED
package/dist/Transducer.min.js
CHANGED
package/dist/Transducer.mjs
CHANGED
package/dist/__.es.js
CHANGED
package/dist/__.es.min.js
CHANGED
package/dist/__.js
CHANGED
package/dist/__.min.js
CHANGED
package/dist/__.mjs
CHANGED
package/dist/all.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Rubico v2.
|
|
2
|
+
* Rubico v2.13.0
|
|
3
3
|
* https://rubico.land/
|
|
4
4
|
*
|
|
5
5
|
* © Richard Yufei Tong, King of Software
|
|
@@ -236,7 +236,8 @@ const functionArrayAllSeries = function (funcs, args) {
|
|
|
236
236
|
const funcsLength = funcs.length, result = []
|
|
237
237
|
let funcsIndex = -1
|
|
238
238
|
while (++funcsIndex < funcsLength) {
|
|
239
|
-
const
|
|
239
|
+
const f = funcs[funcsIndex]
|
|
240
|
+
const resultElement = typeof f == 'function' ? f(...args) : f
|
|
240
241
|
if (isPromise(resultElement)) {
|
|
241
242
|
return resultElement.then(funcConcat(
|
|
242
243
|
curry3(objectSet, result, funcsIndex, __),
|
|
@@ -247,6 +248,90 @@ const functionArrayAllSeries = function (funcs, args) {
|
|
|
247
248
|
return result
|
|
248
249
|
}
|
|
249
250
|
|
|
251
|
+
// argument resolver for curry5
|
|
252
|
+
const curry5ResolveArg0 = (
|
|
253
|
+
baseFunc, arg1, arg2, arg3, arg4,
|
|
254
|
+
) => function arg0Resolver(arg0) {
|
|
255
|
+
return baseFunc(arg0, arg1, arg2, arg3, arg4)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// argument resolver for curry5
|
|
259
|
+
const curry5ResolveArg1 = (
|
|
260
|
+
baseFunc, arg0, arg2, arg3, arg4,
|
|
261
|
+
) => function arg1Resolver(arg1) {
|
|
262
|
+
return baseFunc(arg0, arg1, arg2, arg3, arg4)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// argument resolver for curry5
|
|
266
|
+
const curry5ResolveArg2 = (
|
|
267
|
+
baseFunc, arg0, arg1, arg3, arg4,
|
|
268
|
+
) => function arg2Resolver(arg2) {
|
|
269
|
+
return baseFunc(arg0, arg1, arg2, arg3, arg4)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// argument resolver for curry5
|
|
273
|
+
const curry5ResolveArg3 = (
|
|
274
|
+
baseFunc, arg0, arg1, arg2, arg4,
|
|
275
|
+
) => function arg3Resolver(arg3) {
|
|
276
|
+
return baseFunc(arg0, arg1, arg2, arg3, arg4)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// argument resolver for curry5
|
|
280
|
+
const curry5ResolveArg4 = (
|
|
281
|
+
baseFunc, arg0, arg1, arg2, arg3,
|
|
282
|
+
) => function arg3Resolver(arg4) {
|
|
283
|
+
return baseFunc(arg0, arg1, arg2, arg3, arg4)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const curry5 = function (baseFunc, arg0, arg1, arg2, arg3, arg4) {
|
|
287
|
+
if (arg0 == __) {
|
|
288
|
+
return curry5ResolveArg0(baseFunc, arg1, arg2, arg3, arg4)
|
|
289
|
+
}
|
|
290
|
+
if (arg1 == __) {
|
|
291
|
+
return curry5ResolveArg1(baseFunc, arg0, arg2, arg3, arg4)
|
|
292
|
+
}
|
|
293
|
+
if (arg2 == __) {
|
|
294
|
+
return curry5ResolveArg2(baseFunc, arg0, arg1, arg3, arg4)
|
|
295
|
+
}
|
|
296
|
+
if (arg3 == __) {
|
|
297
|
+
return curry5ResolveArg3(baseFunc, arg0, arg1, arg2, arg4)
|
|
298
|
+
}
|
|
299
|
+
return curry5ResolveArg4(baseFunc, arg0, arg1, arg2, arg3)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const asyncFunctionObjectAllSeries = async function (funcs, args, result, keys, keysIndex) {
|
|
303
|
+
const keysLength = keys.length
|
|
304
|
+
while (++keysIndex < keysLength) {
|
|
305
|
+
const key = keys[keysIndex]
|
|
306
|
+
const f = funcs[key]
|
|
307
|
+
let resultElement = typeof f == 'function' ? f(...args) : f
|
|
308
|
+
if (isPromise(resultElement)) {
|
|
309
|
+
resultElement = await resultElement
|
|
310
|
+
}
|
|
311
|
+
result[key] = resultElement
|
|
312
|
+
}
|
|
313
|
+
return result
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const functionObjectAllSeries = function (funcs, args) {
|
|
317
|
+
const result = {}
|
|
318
|
+
const keys = Object.keys(funcs)
|
|
319
|
+
const keysLength = keys.length
|
|
320
|
+
let keysIndex = -1
|
|
321
|
+
while (++keysIndex < keysLength) {
|
|
322
|
+
const key = keys[keysIndex]
|
|
323
|
+
const f = funcs[key]
|
|
324
|
+
const resultElement = typeof f == 'function' ? f(...args) : f
|
|
325
|
+
if (isPromise(resultElement)) {
|
|
326
|
+
return resultElement.then(funcConcat(
|
|
327
|
+
curry3(objectSet, result, key, __),
|
|
328
|
+
curry5(asyncFunctionObjectAllSeries, funcs, args, __, keys, keysIndex)))
|
|
329
|
+
}
|
|
330
|
+
result[key] = resultElement
|
|
331
|
+
}
|
|
332
|
+
return result
|
|
333
|
+
}
|
|
334
|
+
|
|
250
335
|
const always = value => function getter() { return value }
|
|
251
336
|
|
|
252
337
|
const functionObjectAll = function (funcs, args) {
|
|
@@ -305,14 +390,33 @@ const all = function (...args) {
|
|
|
305
390
|
}
|
|
306
391
|
|
|
307
392
|
all.series = function allSeries(...args) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
393
|
+
if (args.length == 1) {
|
|
394
|
+
const resolversOrValues = args[0]
|
|
395
|
+
if (isPromise(resolversOrValues)) {
|
|
396
|
+
return resolversOrValues.then(_allValues)
|
|
397
|
+
}
|
|
398
|
+
if (areAllValuesNonfunctions(resolversOrValues)) {
|
|
399
|
+
return _allValues(resolversOrValues)
|
|
400
|
+
}
|
|
401
|
+
return isArray(resolversOrValues)
|
|
402
|
+
? curryArgs2(functionArrayAllSeries, resolversOrValues, __)
|
|
403
|
+
: curryArgs2(functionObjectAllSeries, resolversOrValues, __)
|
|
311
404
|
}
|
|
312
|
-
|
|
313
|
-
|
|
405
|
+
|
|
406
|
+
const resolversOrValues = args[args.length - 1]
|
|
407
|
+
const argValues = args.slice(0, -1)
|
|
408
|
+
|
|
409
|
+
if (areAnyValuesPromises(argValues)) {
|
|
410
|
+
return isArray(resolversOrValues)
|
|
411
|
+
? promiseAll(argValues)
|
|
412
|
+
.then(curry2(functionArrayAllSeries, resolversOrValues, __))
|
|
413
|
+
: promiseAll(argValues)
|
|
414
|
+
.then(curry2(functionObjectAllSeries, resolversOrValues, __))
|
|
314
415
|
}
|
|
315
|
-
|
|
416
|
+
|
|
417
|
+
return isArray(resolversOrValues)
|
|
418
|
+
? functionArrayAllSeries(resolversOrValues, argValues)
|
|
419
|
+
: functionObjectAllSeries(resolversOrValues, argValues)
|
|
316
420
|
}
|
|
317
421
|
|
|
318
422
|
export default all
|
package/dist/all.es.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Rubico v2.
|
|
2
|
+
* Rubico v2.13.0
|
|
3
3
|
* https://rubico.land/
|
|
4
4
|
*
|
|
5
5
|
* © Richard Yufei Tong, King of Software
|
|
6
6
|
* Rubico may be freely distributed under the CFOSS license.
|
|
7
7
|
*/
|
|
8
|
-
const isPromise=r=>null!=r&&"function"==typeof r.then,isArray=Array.isArray,areAnyValuesPromises=function(r){if(isArray(r)){const
|
|
8
|
+
const isPromise=r=>null!=r&&"function"==typeof r.then,isArray=Array.isArray,areAnyValuesPromises=function(r){if(isArray(r)){const e=r.length;let n=-1;for(;++n<e;){const e=r[n];if(isPromise(e))return!0}return!1}for(const e in r){const n=r[e];if(isPromise(n))return!0}return!1},areAllValuesNonfunctions=function(r){if(isArray(r)){const e=r.length;let n=-1;for(;++n<e;)if("function"==typeof r[n])return!1;return!0}for(const e in r)if("function"==typeof r[e])return!1;return!0},promiseAll=Promise.all.bind(Promise),promiseObjectAllExecutor=r=>function(e){const n={};let t=0;for(const o in r){const u=r[o];isPromise(u)?(t+=1,u.then((r=>function(o){n[r]=o,t-=1,0==t&&e(n)})(o))):n[o]=u}0==t&&e(n)},promiseObjectAll=r=>new Promise(promiseObjectAllExecutor(r)),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,e)=>function(n){return r(n,e)},curry2ResolveArg1=(r,e)=>function(n){return r(e,n)},curry2=function(r,e,n){return e==__?curry2ResolveArg0(r,n):curry2ResolveArg1(r,e)},curryArgs2ResolveArgs0=(r,e,n)=>function(...n){return r(n,e)},curryArgs2ResolveArgs1=(r,e,n)=>function(...n){return r(e,n)},curryArgs2=function(r,e,n){return e==__?curryArgs2ResolveArgs0(r,n):curryArgs2ResolveArgs1(r,e)},functionArrayAll=function(r,e){const n=r.length,t=Array(n);let o=-1,u=!1;for(;++o<n;){const n=r[o],c="function"==typeof n?n(...e):n;isPromise(c)&&(u=!0),t[o]=c}return u?promiseAll(t):t},funcConcat=(r,e)=>function(...n){const t=r(...n);return isPromise(t)?t.then(e):e(t)},curry3ResolveArg0=(r,e,n)=>function(t){return r(t,e,n)},curry3ResolveArg1=(r,e,n)=>function(t){return r(e,t,n)},curry3ResolveArg2=(r,e,n)=>function(t){return r(e,n,t)},curry3=function(r,e,n,t){return e==__?curry3ResolveArg0(r,n,t):n==__?curry3ResolveArg1(r,e,t):curry3ResolveArg2(r,e,n)},curry4ResolveArg0=(r,e,n,t)=>function(o){return r(o,e,n,t)},curry4ResolveArg1=(r,e,n,t)=>function(o){return r(e,o,n,t)},curry4ResolveArg2=(r,e,n,t)=>function(o){return r(e,n,o,t)},curry4ResolveArg3=(r,e,n,t)=>function(o){return r(e,n,t,o)},curry4=function(r,e,n,t,o){return e==__?curry4ResolveArg0(r,n,t,o):n==__?curry4ResolveArg1(r,e,t,o):t==__?curry4ResolveArg2(r,e,n,o):curry4ResolveArg3(r,e,n,t)},objectSet=function(r,e,n){return r[e]=n,r},asyncFunctionArrayAllSeries=async function(r,e,n,t){const o=r.length;for(;++t<o;){const o=r[t](...e);n[t]=isPromise(o)?await o:o}return n},functionArrayAllSeries=function(r,e){const n=r.length,t=[];let o=-1;for(;++o<n;){const n=r[o],u="function"==typeof n?n(...e):n;if(isPromise(u))return u.then(funcConcat(curry3(objectSet,t,o,__),curry4(asyncFunctionArrayAllSeries,r,e,__,o)));t[o]=u}return t},curry5ResolveArg0=(r,e,n,t,o)=>function(u){return r(u,e,n,t,o)},curry5ResolveArg1=(r,e,n,t,o)=>function(u){return r(e,u,n,t,o)},curry5ResolveArg2=(r,e,n,t,o)=>function(u){return r(e,n,u,t,o)},curry5ResolveArg3=(r,e,n,t,o)=>function(u){return r(e,n,t,u,o)},curry5ResolveArg4=(r,e,n,t,o)=>function(u){return r(e,n,t,o,u)},curry5=function(r,e,n,t,o,u){return e==__?curry5ResolveArg0(r,n,t,o,u):n==__?curry5ResolveArg1(r,e,t,o,u):t==__?curry5ResolveArg2(r,e,n,o,u):o==__?curry5ResolveArg3(r,e,n,t,u):curry5ResolveArg4(r,e,n,t,o)},asyncFunctionObjectAllSeries=async function(r,e,n,t,o){const u=t.length;for(;++o<u;){const u=t[o],c=r[u];let s="function"==typeof c?c(...e):c;isPromise(s)&&(s=await s),n[u]=s}return n},functionObjectAllSeries=function(r,e){const n={},t=Object.keys(r),o=t.length;let u=-1;for(;++u<o;){const o=t[u],c=r[o],s="function"==typeof c?c(...e):c;if(isPromise(s))return s.then(funcConcat(curry3(objectSet,n,o,__),curry5(asyncFunctionObjectAllSeries,r,e,__,t,u)));n[o]=s}return n},always=r=>function(){return r},functionObjectAll=function(r,e){const n={},t=[];for(const o in r){const u=r[o],c="function"==typeof u?u(...e):u;isPromise(c)?t.push(c.then(curry3(objectSet,n,o,__))):n[o]=c}return 0==t.length?n:promiseAll(t).then(always(n))},_allValues=function(r){return isArray(r)?areAnyValuesPromises(r)?promiseAll(r):r:areAnyValuesPromises(r)?promiseObjectAll(r):r},all=function(...r){if(1==r.length){const e=r[0];return isPromise(e)?e.then(_allValues):areAllValuesNonfunctions(e)?_allValues(e):isArray(e)?curryArgs2(functionArrayAll,e,__):curryArgs2(functionObjectAll,e,__)}const e=r[r.length-1],n=r.slice(0,-1);return areAnyValuesPromises(n)?isArray(e)?promiseAll(n).then(curry2(functionArrayAll,e,__)):promiseAll(n).then(curry2(functionObjectAll,e,__)):isArray(e)?functionArrayAll(e,n):functionObjectAll(e,n)};all.series=function(...r){if(1==r.length){const e=r[0];return isPromise(e)?e.then(_allValues):areAllValuesNonfunctions(e)?_allValues(e):isArray(e)?curryArgs2(functionArrayAllSeries,e,__):curryArgs2(functionObjectAllSeries,e,__)}const e=r[r.length-1],n=r.slice(0,-1);return areAnyValuesPromises(n)?isArray(e)?promiseAll(n).then(curry2(functionArrayAllSeries,e,__)):promiseAll(n).then(curry2(functionObjectAllSeries,e,__)):isArray(e)?functionArrayAllSeries(e,n):functionObjectAllSeries(e,n)};export default all;
|