rubico 2.4.2 → 2.6.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 +3 -0
- package/_internal/arrayMapPool.js +11 -19
- package/_internal/mapMapPool.js +80 -0
- package/_internal/mapMapSeries.js +62 -0
- package/_internal/objectForEachSeries.js +6 -4
- package/_internal/objectMapPool.js +77 -0
- package/_internal/objectMapSeries.js +62 -0
- package/_internal/setAdd.js +14 -0
- package/_internal/setMapPool.js +79 -0
- package/_internal/setMapSeries.js +61 -0
- package/_internal/stringMap.js +1 -1
- package/_internal/stringMapPool.js +22 -0
- package/_internal/stringMapSeries.js +31 -0
- package/all.js +11 -1
- package/and.js +9 -0
- package/assign.js +14 -1
- package/compose.js +8 -0
- 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 +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 +11 -8
- package/dist/forEach.es.min.js +2 -2
- package/dist/forEach.js +11 -8
- package/dist/forEach.min.js +2 -2
- package/dist/forEach.mjs +11 -8
- 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 +382 -51
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +382 -51
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +382 -51
- 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 +362 -33
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +362 -33
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +362 -33
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +362 -33
- 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 +38 -1
- package/dist/tap.es.min.js +2 -2
- package/dist/tap.js +38 -1
- package/dist/tap.min.js +2 -2
- package/dist/tap.mjs +38 -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 -1
- package/dist/transform.es.min.js +1 -1
- package/dist/transform.js +1 -1
- package/dist/transform.min.js +1 -1
- package/dist/transform.mjs +1 -1
- 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 +382 -51
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +382 -51
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +382 -51
- 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 +38 -1
- package/dist/x/trace.es.min.js +2 -2
- package/dist/x/trace.js +38 -1
- package/dist/x/trace.min.js +2 -2
- package/dist/x/trace.mjs +38 -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 +6 -0
- package/es.js +362 -33
- package/every.js +6 -0
- package/filter.js +9 -0
- package/flatMap.js +7 -0
- package/forEach.js +22 -3
- package/get.js +6 -0
- package/gt.js +6 -0
- package/gte.js +6 -0
- package/index.js +362 -33
- package/lt.js +6 -0
- package/lte.js +6 -0
- package/map.js +172 -44
- package/not.js +8 -0
- package/omit.js +7 -0
- package/or.js +9 -0
- package/package.json +1 -1
- package/pick.js +7 -0
- package/pipe.js +8 -0
- package/reduce.js +8 -0
- package/set.js +6 -0
- package/some.js +6 -0
- package/switchCase.js +12 -0
- package/tap.js +11 -0
- package/transform.js +38 -10
- package/tryCatch.js +14 -0
package/dist/x/maxBy.js
CHANGED
package/dist/x/maxBy.min.js
CHANGED
package/dist/x/maxBy.mjs
CHANGED
package/dist/x/noop.es.js
CHANGED
package/dist/x/noop.es.min.js
CHANGED
package/dist/x/noop.js
CHANGED
package/dist/x/noop.min.js
CHANGED
package/dist/x/noop.mjs
CHANGED
package/dist/x/pluck.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.
|
|
2
|
+
* rubico v2.6.0
|
|
3
3
|
* https://github.com/a-synchronous/rubico
|
|
4
4
|
* (c) 2019-2024 Richard Tong
|
|
5
5
|
* rubico may be freely distributed under the MIT license.
|
|
@@ -74,35 +74,6 @@ const curry2 = function (baseFunc, arg0, arg1) {
|
|
|
74
74
|
: curry2ResolveArg1(baseFunc, arg0)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const isArray = Array.isArray
|
|
78
|
-
|
|
79
|
-
const isObject = value => {
|
|
80
|
-
if (value == null) {
|
|
81
|
-
return false
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const typeofValue = typeof value
|
|
85
|
-
return (typeofValue == 'object') || (typeofValue == 'function')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const promiseAll = Promise.all.bind(Promise)
|
|
89
|
-
|
|
90
|
-
const arrayMap = function (array, mapper) {
|
|
91
|
-
const arrayLength = array.length,
|
|
92
|
-
result = Array(arrayLength)
|
|
93
|
-
let index = -1,
|
|
94
|
-
isAsync = false
|
|
95
|
-
|
|
96
|
-
while (++index < arrayLength) {
|
|
97
|
-
const resultItem = mapper(array[index], index, array)
|
|
98
|
-
if (isPromise(resultItem)) {
|
|
99
|
-
isAsync = true
|
|
100
|
-
}
|
|
101
|
-
result[index] = resultItem
|
|
102
|
-
}
|
|
103
|
-
return isAsync ? promiseAll(result) : result
|
|
104
|
-
}
|
|
105
|
-
|
|
106
77
|
// argument resolver for curry3
|
|
107
78
|
const curry3ResolveArg0 = (
|
|
108
79
|
baseFunc, arg1, arg2,
|
|
@@ -134,6 +105,35 @@ const curry3 = function (baseFunc, arg0, arg1, arg2) {
|
|
|
134
105
|
return curry3ResolveArg2(baseFunc, arg0, arg1)
|
|
135
106
|
}
|
|
136
107
|
|
|
108
|
+
const isArray = Array.isArray
|
|
109
|
+
|
|
110
|
+
const isObject = value => {
|
|
111
|
+
if (value == null) {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const typeofValue = typeof value
|
|
116
|
+
return (typeofValue == 'object') || (typeofValue == 'function')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const promiseAll = Promise.all.bind(Promise)
|
|
120
|
+
|
|
121
|
+
const arrayMap = function (array, mapper) {
|
|
122
|
+
const arrayLength = array.length,
|
|
123
|
+
result = Array(arrayLength)
|
|
124
|
+
let index = -1,
|
|
125
|
+
isAsync = false
|
|
126
|
+
|
|
127
|
+
while (++index < arrayLength) {
|
|
128
|
+
const resultItem = mapper(array[index], index, array)
|
|
129
|
+
if (isPromise(resultItem)) {
|
|
130
|
+
isAsync = true
|
|
131
|
+
}
|
|
132
|
+
result[index] = resultItem
|
|
133
|
+
}
|
|
134
|
+
return isAsync ? promiseAll(result) : result
|
|
135
|
+
}
|
|
136
|
+
|
|
137
137
|
const callPropUnary = (value, property, arg0) => value[property](arg0)
|
|
138
138
|
|
|
139
139
|
const stringMap = function (string, mapper) {
|
|
@@ -292,6 +292,140 @@ const arrayMapSeries = function (array, mapper) {
|
|
|
292
292
|
return result
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
const stringMapSeries = function (string, mapper) {
|
|
296
|
+
const result = arrayMapSeries(string, mapper)
|
|
297
|
+
return isPromise(result)
|
|
298
|
+
? result.then(curry3(callPropUnary, __, 'join', ''))
|
|
299
|
+
: result.join('')
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const thunkify4 = (func, arg0, arg1, arg2, arg3) => function thunk() {
|
|
303
|
+
return func(arg0, arg1, arg2, arg3)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// _objectMapSeriesAsync(
|
|
307
|
+
// object Object,
|
|
308
|
+
// f function,
|
|
309
|
+
// result Object,
|
|
310
|
+
// doneKeys Object
|
|
311
|
+
// ) -> Promise<object>
|
|
312
|
+
const _objectMapSeriesAsync = async function (object, f, result, doneKeys) {
|
|
313
|
+
for (const key in object) {
|
|
314
|
+
if (key in doneKeys) {
|
|
315
|
+
continue
|
|
316
|
+
}
|
|
317
|
+
let resultItem = f(object[key])
|
|
318
|
+
if (isPromise(resultItem)) {
|
|
319
|
+
resultItem = await resultItem
|
|
320
|
+
}
|
|
321
|
+
result[key] = resultItem
|
|
322
|
+
}
|
|
323
|
+
return result
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const objectMapSeries = function (object, f) {
|
|
327
|
+
const result = {}
|
|
328
|
+
const doneKeys = {}
|
|
329
|
+
for (const key in object) {
|
|
330
|
+
doneKeys[key] = true
|
|
331
|
+
const resultItem = f(object[key], key, object)
|
|
332
|
+
if (isPromise(resultItem)) {
|
|
333
|
+
return resultItem.then(funcConcat(
|
|
334
|
+
curry3(objectSet, result, key, __),
|
|
335
|
+
thunkify4(_objectMapSeriesAsync, object, f, result, doneKeys),
|
|
336
|
+
))
|
|
337
|
+
}
|
|
338
|
+
result[key] = resultItem
|
|
339
|
+
}
|
|
340
|
+
return result
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const thunkify3 = (func, arg0, arg1, arg2) => function thunk() {
|
|
344
|
+
return func(arg0, arg1, arg2)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const setAdd = function (set, value) {
|
|
348
|
+
set.add(value)
|
|
349
|
+
return set
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// _setMapSeriesAsync(
|
|
353
|
+
// iterator Iterator,
|
|
354
|
+
// f function,
|
|
355
|
+
// result Set,
|
|
356
|
+
// ) -> Promise<Set>
|
|
357
|
+
const _setMapSeriesAsync = async function (iterator, f, result) {
|
|
358
|
+
let iteration = iterator.next()
|
|
359
|
+
while (!iteration.done) {
|
|
360
|
+
let resultItem = f(iteration.value)
|
|
361
|
+
if (isPromise(resultItem)) {
|
|
362
|
+
resultItem = await resultItem
|
|
363
|
+
}
|
|
364
|
+
result.add(resultItem)
|
|
365
|
+
iteration = iterator.next()
|
|
366
|
+
}
|
|
367
|
+
return result
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const setMapSeries = function (set, f) {
|
|
371
|
+
const result = new Set()
|
|
372
|
+
const iterator = set[symbolIterator]()
|
|
373
|
+
let iteration = iterator.next()
|
|
374
|
+
while (!iteration.done) {
|
|
375
|
+
const resultItem = f(iteration.value)
|
|
376
|
+
if (isPromise(resultItem)) {
|
|
377
|
+
return resultItem.then(funcConcat(
|
|
378
|
+
curry2(setAdd, result, __),
|
|
379
|
+
thunkify3(_setMapSeriesAsync, iterator, f, result),
|
|
380
|
+
))
|
|
381
|
+
}
|
|
382
|
+
result.add(resultItem)
|
|
383
|
+
iteration = iterator.next()
|
|
384
|
+
}
|
|
385
|
+
return result
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const mapSet = function setting(source, key, value) {
|
|
389
|
+
return source.set(key, value)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// _mapMapSeriesAsync(
|
|
393
|
+
// iterator Iterator,
|
|
394
|
+
// f function,
|
|
395
|
+
// result Map,
|
|
396
|
+
// ) -> Promise<Map>
|
|
397
|
+
const _mapMapSeriesAsync = async function (iterator, f, result) {
|
|
398
|
+
let iteration = iterator.next()
|
|
399
|
+
while (!iteration.done) {
|
|
400
|
+
let resultItem = f(iteration.value[1])
|
|
401
|
+
if (isPromise(resultItem)) {
|
|
402
|
+
resultItem = await resultItem
|
|
403
|
+
}
|
|
404
|
+
result.set(iteration.value[0], resultItem)
|
|
405
|
+
iteration = iterator.next()
|
|
406
|
+
}
|
|
407
|
+
return result
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const mapMapSeries = function (map, f) {
|
|
411
|
+
const result = new Map()
|
|
412
|
+
const iterator = map[symbolIterator]()
|
|
413
|
+
let iteration = iterator.next()
|
|
414
|
+
while (!iteration.done) {
|
|
415
|
+
const key = iteration.value[0]
|
|
416
|
+
const resultItem = f(iteration.value[1])
|
|
417
|
+
if (isPromise(resultItem)) {
|
|
418
|
+
return resultItem.then(funcConcat(
|
|
419
|
+
curry3(mapSet, result, key, __),
|
|
420
|
+
thunkify3(_mapMapSeriesAsync, iterator, f, result),
|
|
421
|
+
))
|
|
422
|
+
}
|
|
423
|
+
result.set(key, resultItem)
|
|
424
|
+
iteration = iterator.next()
|
|
425
|
+
}
|
|
426
|
+
return result
|
|
427
|
+
}
|
|
428
|
+
|
|
295
429
|
const tapSync = func => function tapping(...args) {
|
|
296
430
|
func(...args)
|
|
297
431
|
return args[0]
|
|
@@ -300,15 +434,14 @@ const tapSync = func => function tapping(...args) {
|
|
|
300
434
|
const promiseRace = Promise.race.bind(Promise)
|
|
301
435
|
|
|
302
436
|
const arrayMapPoolAsync = async function (
|
|
303
|
-
array,
|
|
437
|
+
array, f, concurrencyLimit, result, index, promises,
|
|
304
438
|
) {
|
|
305
439
|
const arrayLength = array.length
|
|
306
440
|
while (++index < arrayLength) {
|
|
307
441
|
if (promises.size >= concurrencyLimit) {
|
|
308
442
|
await promiseRace(promises)
|
|
309
443
|
}
|
|
310
|
-
|
|
311
|
-
const resultItem = mapper(array[index])
|
|
444
|
+
const resultItem = f(array[index])
|
|
312
445
|
if (isPromise(resultItem)) {
|
|
313
446
|
const selfDeletingPromise = resultItem.then(
|
|
314
447
|
tapSync(() => promises.delete(selfDeletingPromise)))
|
|
@@ -321,13 +454,12 @@ const arrayMapPoolAsync = async function (
|
|
|
321
454
|
return promiseAll(result)
|
|
322
455
|
}
|
|
323
456
|
|
|
324
|
-
const arrayMapPool = function (array,
|
|
457
|
+
const arrayMapPool = function (array, concurrency, f) {
|
|
325
458
|
const arrayLength = array.length,
|
|
326
459
|
result = Array(arrayLength)
|
|
327
460
|
let index = -1
|
|
328
461
|
while (++index < arrayLength) {
|
|
329
|
-
|
|
330
|
-
const resultItem = mapper(array[index])
|
|
462
|
+
const resultItem = f(array[index])
|
|
331
463
|
if (isPromise(resultItem)) {
|
|
332
464
|
const promises = new Set(),
|
|
333
465
|
selfDeletingPromise = resultItem.then(
|
|
@@ -335,13 +467,167 @@ const arrayMapPool = function (array, mapper, concurrentLimit) {
|
|
|
335
467
|
promises.add(selfDeletingPromise)
|
|
336
468
|
result[index] = selfDeletingPromise
|
|
337
469
|
return arrayMapPoolAsync(
|
|
338
|
-
array,
|
|
470
|
+
array, f, concurrency, result, index, promises)
|
|
339
471
|
}
|
|
340
472
|
result[index] = resultItem
|
|
341
473
|
}
|
|
342
474
|
return result
|
|
343
475
|
}
|
|
344
476
|
|
|
477
|
+
const stringMapPool = function (s, concurrency, f) {
|
|
478
|
+
const result = arrayMapPool(s, concurrency, f)
|
|
479
|
+
return isPromise(result)
|
|
480
|
+
? result.then(curry3(callPropUnary, __, 'join', ''))
|
|
481
|
+
: result.join('')
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const _setMapPoolAsync = async function (
|
|
485
|
+
s, iterator, concurrency, f, result, promises,
|
|
486
|
+
) {
|
|
487
|
+
let iteration = iterator.next()
|
|
488
|
+
while (!iteration.done) {
|
|
489
|
+
if (promises.size >= concurrency) {
|
|
490
|
+
await promiseRace(promises)
|
|
491
|
+
}
|
|
492
|
+
const resultItem = f(iteration.value, iteration.value, s)
|
|
493
|
+
if (isPromise(resultItem)) {
|
|
494
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
495
|
+
promises.delete(selfDeletingPromise)
|
|
496
|
+
result.add(resolvedValue)
|
|
497
|
+
})
|
|
498
|
+
promises.add(selfDeletingPromise)
|
|
499
|
+
} else {
|
|
500
|
+
result.add(resultItem)
|
|
501
|
+
}
|
|
502
|
+
iteration = iterator.next()
|
|
503
|
+
}
|
|
504
|
+
if (promises.size > 0) {
|
|
505
|
+
await promiseAll(promises)
|
|
506
|
+
}
|
|
507
|
+
return result
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const setMapPool = function (s, concurrency, f) {
|
|
511
|
+
const result = new Set()
|
|
512
|
+
const iterator = s[symbolIterator]()
|
|
513
|
+
let iteration = iterator.next()
|
|
514
|
+
while (!iteration.done) {
|
|
515
|
+
const resultItem = f(iteration.value, iteration.value, s)
|
|
516
|
+
if (isPromise(resultItem)) {
|
|
517
|
+
const promises = new Set()
|
|
518
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
519
|
+
promises.delete(selfDeletingPromise)
|
|
520
|
+
result.add(resolvedValue)
|
|
521
|
+
})
|
|
522
|
+
promises.add(selfDeletingPromise)
|
|
523
|
+
return _setMapPoolAsync(s, iterator, concurrency, f, result, promises)
|
|
524
|
+
}
|
|
525
|
+
result.add(resultItem)
|
|
526
|
+
iteration = iterator.next()
|
|
527
|
+
}
|
|
528
|
+
return result
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const _mapMapPoolAsync = async function (
|
|
532
|
+
m, iterator, concurrency, f, result, promises,
|
|
533
|
+
) {
|
|
534
|
+
let iteration = iterator.next()
|
|
535
|
+
while (!iteration.done) {
|
|
536
|
+
if (promises.size >= concurrency) {
|
|
537
|
+
await promiseRace(promises)
|
|
538
|
+
}
|
|
539
|
+
const key = iteration.value[0]
|
|
540
|
+
const resultItem = f(iteration.value[1], key, m)
|
|
541
|
+
if (isPromise(resultItem)) {
|
|
542
|
+
result.set(key, resultItem)
|
|
543
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
544
|
+
promises.delete(selfDeletingPromise)
|
|
545
|
+
result.set(key, resolvedValue)
|
|
546
|
+
})
|
|
547
|
+
promises.add(selfDeletingPromise)
|
|
548
|
+
} else {
|
|
549
|
+
result.set(key, resultItem)
|
|
550
|
+
}
|
|
551
|
+
iteration = iterator.next()
|
|
552
|
+
}
|
|
553
|
+
if (promises.size > 0) {
|
|
554
|
+
await promiseAll(promises)
|
|
555
|
+
}
|
|
556
|
+
return result
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const mapMapPool = function (m, concurrency, f) {
|
|
560
|
+
const result = new Map()
|
|
561
|
+
const iterator = m[symbolIterator]()
|
|
562
|
+
let iteration = iterator.next()
|
|
563
|
+
while (!iteration.done) {
|
|
564
|
+
const key = iteration.value[0]
|
|
565
|
+
const resultItem = f(iteration.value[1], key, m)
|
|
566
|
+
if (isPromise(resultItem)) {
|
|
567
|
+
const promises = new Set()
|
|
568
|
+
result.set(key, resultItem)
|
|
569
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
570
|
+
promises.delete(selfDeletingPromise)
|
|
571
|
+
result.set(key, resolvedValue)
|
|
572
|
+
})
|
|
573
|
+
promises.add(selfDeletingPromise)
|
|
574
|
+
return _mapMapPoolAsync(m, iterator, concurrency, f, result, promises)
|
|
575
|
+
}
|
|
576
|
+
result.set(key, resultItem)
|
|
577
|
+
iteration = iterator.next()
|
|
578
|
+
}
|
|
579
|
+
return result
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const _objectMapPoolAsync = async function (
|
|
583
|
+
o, concurrency, f, result, doneKeys, promises,
|
|
584
|
+
) {
|
|
585
|
+
for (const key in o) {
|
|
586
|
+
if (key in doneKeys) {
|
|
587
|
+
continue
|
|
588
|
+
}
|
|
589
|
+
if (promises.size >= concurrency) {
|
|
590
|
+
await promiseRace(promises)
|
|
591
|
+
}
|
|
592
|
+
const resultItem = f(o[key], key, o)
|
|
593
|
+
if (isPromise(resultItem)) {
|
|
594
|
+
result[key] = resultItem
|
|
595
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
596
|
+
promises.delete(selfDeletingPromise)
|
|
597
|
+
result[key] = resolvedValue
|
|
598
|
+
})
|
|
599
|
+
promises.add(selfDeletingPromise)
|
|
600
|
+
} else {
|
|
601
|
+
result[key] = resultItem
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (promises.size > 0) {
|
|
605
|
+
await promiseAll(promises)
|
|
606
|
+
}
|
|
607
|
+
return result
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const objectMapPool = function (o, concurrency, f) {
|
|
611
|
+
const result = {}
|
|
612
|
+
const doneKeys = {}
|
|
613
|
+
for (const key in o) {
|
|
614
|
+
doneKeys[key] = true
|
|
615
|
+
const resultItem = f(o[key], key, o)
|
|
616
|
+
if (isPromise(resultItem)) {
|
|
617
|
+
const promises = new Set()
|
|
618
|
+
result[key] = resultItem
|
|
619
|
+
const selfDeletingPromise = resultItem.then(resolvedValue => {
|
|
620
|
+
promises.delete(selfDeletingPromise)
|
|
621
|
+
result[key] = resolvedValue
|
|
622
|
+
})
|
|
623
|
+
promises.add(selfDeletingPromise)
|
|
624
|
+
return _objectMapPoolAsync(o, concurrency, f, result, doneKeys, promises)
|
|
625
|
+
}
|
|
626
|
+
result[key] = resultItem
|
|
627
|
+
}
|
|
628
|
+
return result
|
|
629
|
+
}
|
|
630
|
+
|
|
345
631
|
const _curryArity = (arity, func, args) => function curried(...curriedArgs) {
|
|
346
632
|
const argsLength = args.length,
|
|
347
633
|
curriedArgsLength = curriedArgs.length,
|
|
@@ -420,10 +706,6 @@ const objectMapEntries = function (object, mapper) {
|
|
|
420
706
|
: promiseAll(promises).then(always(result))
|
|
421
707
|
}
|
|
422
708
|
|
|
423
|
-
const mapSet = function setting(source, key, value) {
|
|
424
|
-
return source.set(key, value)
|
|
425
|
-
}
|
|
426
|
-
|
|
427
709
|
// (mapper function, result Map, promises Array<Promise>) => (key any, value any) => ()
|
|
428
710
|
const mapMapEntriesForEachCallback = (
|
|
429
711
|
mapper, result, promises,
|
|
@@ -481,7 +763,7 @@ const _map = function (value, mapper) {
|
|
|
481
763
|
}
|
|
482
764
|
|
|
483
765
|
const map = function (arg0, arg1) {
|
|
484
|
-
if (
|
|
766
|
+
if (arg1 == null) {
|
|
485
767
|
return curry2(_map, __, arg0)
|
|
486
768
|
}
|
|
487
769
|
return isPromise(arg0)
|
|
@@ -504,7 +786,7 @@ const _mapEntries = (value, mapper) => {
|
|
|
504
786
|
}
|
|
505
787
|
|
|
506
788
|
map.entries = function mapEntries(arg0, arg1) {
|
|
507
|
-
if (
|
|
789
|
+
if (arg1 == null) {
|
|
508
790
|
return curry2(_mapEntries, __, arg0)
|
|
509
791
|
}
|
|
510
792
|
return isPromise(arg0)
|
|
@@ -512,18 +794,67 @@ map.entries = function mapEntries(arg0, arg1) {
|
|
|
512
794
|
: _mapEntries(arg0, arg1)
|
|
513
795
|
}
|
|
514
796
|
|
|
515
|
-
|
|
516
|
-
if (isArray(
|
|
517
|
-
return arrayMapSeries(
|
|
797
|
+
const _mapSeries = function (collection, f) {
|
|
798
|
+
if (isArray(collection)) {
|
|
799
|
+
return arrayMapSeries(collection, f)
|
|
800
|
+
}
|
|
801
|
+
if (collection == null) {
|
|
802
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
518
803
|
}
|
|
519
|
-
|
|
804
|
+
|
|
805
|
+
if (typeof collection == 'string' || collection.constructor == String) {
|
|
806
|
+
return stringMapSeries(collection, f)
|
|
807
|
+
}
|
|
808
|
+
if (collection.constructor == Set) {
|
|
809
|
+
return setMapSeries(collection, f)
|
|
810
|
+
}
|
|
811
|
+
if (collection.constructor == Map) {
|
|
812
|
+
return mapMapSeries(collection, f)
|
|
813
|
+
}
|
|
814
|
+
if (collection.constructor == Object) {
|
|
815
|
+
return objectMapSeries(collection, f)
|
|
816
|
+
}
|
|
817
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
520
818
|
}
|
|
521
819
|
|
|
522
|
-
map.
|
|
523
|
-
if (
|
|
524
|
-
return
|
|
820
|
+
map.series = function mapSeries(arg0, arg1) {
|
|
821
|
+
if (arg1 == null) {
|
|
822
|
+
return curry2(_mapSeries, __, arg0)
|
|
525
823
|
}
|
|
526
|
-
|
|
824
|
+
return isPromise(arg0)
|
|
825
|
+
? arg0.then(curry2(_mapSeries, __, arg1))
|
|
826
|
+
: _mapSeries(arg0, arg1)
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
const _mapPool = function (collection, concurrency, f) {
|
|
830
|
+
if (isArray(collection)) {
|
|
831
|
+
return arrayMapPool(collection, concurrency, f)
|
|
832
|
+
}
|
|
833
|
+
if (collection == null) {
|
|
834
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
835
|
+
}
|
|
836
|
+
if (typeof collection == 'string' || collection.constructor == String) {
|
|
837
|
+
return stringMapPool(collection, concurrency, f)
|
|
838
|
+
}
|
|
839
|
+
if (collection.constructor == Set) {
|
|
840
|
+
return setMapPool(collection, concurrency, f)
|
|
841
|
+
}
|
|
842
|
+
if (collection.constructor == Map) {
|
|
843
|
+
return mapMapPool(collection, concurrency, f)
|
|
844
|
+
}
|
|
845
|
+
if (collection.constructor == Object) {
|
|
846
|
+
return objectMapPool(collection, concurrency, f)
|
|
847
|
+
}
|
|
848
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
map.pool = function mapPool(arg0, arg1, arg2) {
|
|
852
|
+
if (arg2 == null) {
|
|
853
|
+
return curry3(_mapPool, __, arg0, arg1)
|
|
854
|
+
}
|
|
855
|
+
return isPromise(arg0)
|
|
856
|
+
? arg0.then(curry3(_mapPool, __, arg1, arg2))
|
|
857
|
+
: _mapPool(arg0, arg1, arg2)
|
|
527
858
|
}
|
|
528
859
|
|
|
529
860
|
const memoizeCappedUnary = function (func, cap) {
|
package/dist/x/pluck.es.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.
|
|
2
|
+
* rubico v2.6.0
|
|
3
3
|
* https://github.com/a-synchronous/rubico
|
|
4
4
|
* (c) 2019-2024 Richard Tong
|
|
5
5
|
* rubico may be freely distributed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
-
const isPromise=r=>null!=r&&"function"==typeof r.then,funcConcat=(r,t)=>function(...e){const n=r(...e);return isPromise(n)?n.then(t):t(n)},symbolIterator=Symbol.iterator,MappingIterator=(r,t)=>({toString:()=>"[object MappingIterator]",[symbolIterator](){return this},next(){const e=r.next();return e.done?e:{value:t(e.value),done:!1}}}),NextIteration=r=>({value:r,done:!1}),symbolAsyncIterator=Symbol.asyncIterator,MappingAsyncIterator=(r,t)=>({[symbolAsyncIterator](){return this},async next(){const e=await r.next();if(e.done)return e;const n=t(e.value);return isPromise(n)?n.then(NextIteration):{value:n,done:!1}}}),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,t)=>function(e){return r(e,t)},curry2ResolveArg1=(r,t)=>function(e){return r(t,e)},curry2=function(r,t,e){return t==__?curry2ResolveArg0(r,e):curry2ResolveArg1(r,t)},isArray=Array.isArray,isObject=r=>{if(null==r)return!1;const t=typeof r;return"object"==t||"function"==t},promiseAll=Promise.all.bind(Promise),arrayMap=function(r,t){const e=r.length,n=Array(e);let o=-1,s=!1;for(;++o<e;){const e=t(r[o],o,r);isPromise(e)&&(s=!0),n[o]=e}return s?promiseAll(n):n},curry3ResolveArg0=(r,t,e)=>function(n){return r(n,t,e)},curry3ResolveArg1=(r,t,e)=>function(n){return r(t,n,e)},curry3ResolveArg2=(r,t,e)=>function(n){return r(t,e,n)},curry3=function(r,t,e,n){return t==__?curry3ResolveArg0(r,e,n):e==__?curry3ResolveArg1(r,t,n):curry3ResolveArg2(r,t,e)},callPropUnary=(r,t,e)=>r[t](e),stringMap=function(r,t){const e=arrayMap(r,t);return isPromise(e)?e.then(curry3(callPropUnary,__,"join","")):e.join("")},always=r=>function(){return r},setMap=function(r,t){const e=new Set,n=[];for(const o of r){const s=t(o,o,r);isPromise(s)?n.push(s.then(curry3(callPropUnary,e,"add",__))):e.add(s)}return 0==n.length?e:promiseAll(n).then(always(e))},curry4ResolveArg0=(r,t,e,n)=>function(o){return r(o,t,e,n)},curry4ResolveArg1=(r,t,e,n)=>function(o){return r(t,o,e,n)},curry4ResolveArg2=(r,t,e,n)=>function(o){return r(t,e,o,n)},curry4ResolveArg3=(r,t,e,n)=>function(o){return r(t,e,n,o)},curry4=function(r,t,e,n,o){return t==__?curry4ResolveArg0(r,e,n,o):e==__?curry4ResolveArg1(r,t,n,o):n==__?curry4ResolveArg2(r,t,e,o):curry4ResolveArg3(r,t,e,n)},callPropBinary=(r,t,e,n)=>r[t](e,n),mapMap=function(r,t){const e=new Map,n=[];for(const[o,s]of r){const c=t(s,o,r);isPromise(c)?n.push(c.then(curry4(callPropBinary,e,"set",o,__))):e.set(o,c)}return 0==n.length?e:promiseAll(n).then(always(e))},promiseObjectAllExecutor=r=>function(t){const e={};let n=0;for(const o in r){const s=r[o];isPromise(s)?(n+=1,s.then((r=>function(o){e[r]=o,n-=1,0==n&&t(e)})(o))):e[o]=s}0==n&&t(e)},promiseObjectAll=r=>new Promise(promiseObjectAllExecutor(r)),objectMap=function(r,t){const e={};let n=!1;for(const o in r){const s=t(r[o],o,r);isPromise(s)&&(n=!0),e[o]=s}return n?promiseObjectAll(e):e},objectSet=function(r,t,e){return r[t]=e,r},arrayMapSeriesAsync=async function(r,t,e,n){const o=r.length;for(;++n<o;){const o=t(r[n],n);e[n]=isPromise(o)?await o:o}return e},arrayMapSeries=function(r,t){const e=r.length,n=Array(e);let o=-1;for(;++o<e;){const e=t(r[o],o);if(isPromise(e))return e.then(funcConcat(curry3(objectSet,n,o,__),curry4(arrayMapSeriesAsync,r,t,__,o)));n[o]=e}return n},tapSync=r=>function(...t){return r(...t),t[0]},promiseRace=Promise.race.bind(Promise),arrayMapPoolAsync=async function(r,t,e,n,o,s){const c=r.length;for(;++o<c;){s.size>=e&&await promiseRace(s);const c=t(r[o]);if(isPromise(c)){const r=c.then(tapSync((()=>s.delete(r))));s.add(r),n[o]=r}else n[o]=c}return promiseAll(n)},arrayMapPool=function(r,t,e){const n=r.length,o=Array(n);let s=-1;for(;++s<n;){const n=t(r[s]);if(isPromise(n)){const c=new Set,i=n.then(tapSync((()=>c.delete(i))));return c.add(i),o[s]=i,arrayMapPoolAsync(r,t,e,o,s,c)}o[s]=n}return o},_curryArity=(r,t,e)=>function(...n){const o=e.length,s=n.length,c=[];let i=-1,a=-1,u=0;for(;++i<o;){const o=e[i];if(o==__&&(a+=1)<s){const r=n[a];r==__&&(u+=1),c.push(r)}else c.push(o);if(c.length==r)return 0==u?t(...c):curryArity(r,t,c)}for(;++a<s;){const e=n[a];if(e==__&&(u+=1),c.push(e),c.length==r)return 0==u?t(...c):curryArity(r,t,c)}return curryArity(r,t,c)},curryArity=function(r,t,e){const n=e.length;if(n<r)return _curryArity(r,t,e);let o=-1;for(;++o<n;){if(e[o]==__)return _curryArity(r,t,e)}return t(...e)},spread2=r=>function([t,e]){return r(t,e)},objectMapEntries=function(r,t){const e={},n=[];for(const o in r){const s=t([o,r[o]]);isPromise(s)?n.push(s.then(spread2(curryArity(3,objectSet,[e])))):e[s[0]]=s[1]}return 0==n.length?e:promiseAll(n).then(always(e))},mapSet=function(r,t,e){return r.set(t,e)},mapMapEntriesForEachCallback=(r,t,e)=>function(n,o){const s=r([o,n]);isPromise(s)?e.push(s.then(spread2(curryArity(3,mapSet,[t])))):t.set(s[0],s[1])},mapMapEntries=function(r,t){const e=new Map,n=[];return r.forEach(mapMapEntriesForEachCallback(t,e,n)),0==n.length?e:promiseAll(n).then(always(e))},_map=function(r,t){return isArray(r)?arrayMap(r,t):null==r?r:"function"==typeof r.then?r.then(t):"function"==typeof r.map?r.map(t):"string"==typeof r||r.constructor==String?stringMap(r,t):r.constructor==Set?setMap(r,t):r.constructor==Map?mapMap(r,t):"function"==typeof r[symbolIterator]?MappingIterator(r[symbolIterator](),t):"function"==typeof r[symbolAsyncIterator]?MappingAsyncIterator(r[symbolAsyncIterator](),t):r.constructor==Object?objectMap(r,t):t(r)},map=function(r,t){return"function"==typeof r?curry2(_map,__,r):isPromise(r)?r.then(curry2(_map,__,t)):_map(r,t)},_mapEntries=(r,t)=>{if(null==r)throw new TypeError("value is not an Object or Map");if(r.constructor==Object)return objectMapEntries(r,t);if(r.constructor==Map)return mapMapEntries(r,t);throw new TypeError("value is not an Object or Map")};map.entries=function(r,t){return"function"==typeof r?curry2(_mapEntries,__,r):isPromise(r)?r.then(curry2(_mapEntries,__,t)):_mapEntries(r,t)},map.series=r=>function(t){if(isArray(t))return arrayMapSeries(t,r);throw new TypeError(`${t} is not an Array`)},map.pool=(r,t)=>function(e){if(isArray(e))return arrayMapPool(e,t,r);throw new TypeError(`${e} is not an Array`)};const memoizeCappedUnary=function(r,t){const e=new Map,n=function(n){if(e.has(n))return e.get(n);const o=r(n);return e.set(n,o),e.size>t&&e.clear(),o};return n.cache=e,n},pathDelimiters=/[.|[|\]]+/,parsePropertyPath=function(r){const t=r.length-1,e="["==r[0],n="]"==r[t];return e&&n?r.slice(1,t).split(pathDelimiters):e?r.slice(1).split(pathDelimiters):n?r.slice(0,t).split(pathDelimiters):r.split(pathDelimiters)},memoizedCappedParsePropertyPath=memoizeCappedUnary(parsePropertyPath,500),propertyPathToArray=r=>isArray(r)?r:"string"==typeof r?memoizedCappedParsePropertyPath(r):[r],getByPath=function(r,t){const e=propertyPathToArray(t),n=e.length;let o=-1,s=r;for(;++o<n;)if(s=s[e[o]],null==s)return;return s},_get=function(r,t,e){const n=null==r?void 0:getByPath(r,t);return void 0===n?"function"==typeof e?e(r):e:n},get=function(r,t,e){return"string"==typeof r||"number"==typeof r||isArray(r)?curry3(_get,__,r,t):isPromise(r)?r.then(curry3(_get,__,t,e)):_get(r,t,e)},pluck=function(...r){const t=r.pop(),e=get(t);return 0==r.length?map(e):map(r[0],e)};export default pluck;
|
|
7
|
+
const isPromise=r=>null!=r&&"function"==typeof r.then,funcConcat=(r,t)=>function(...e){const n=r(...e);return isPromise(n)?n.then(t):t(n)},symbolIterator=Symbol.iterator,MappingIterator=(r,t)=>({toString:()=>"[object MappingIterator]",[symbolIterator](){return this},next(){const e=r.next();return e.done?e:{value:t(e.value),done:!1}}}),NextIteration=r=>({value:r,done:!1}),symbolAsyncIterator=Symbol.asyncIterator,MappingAsyncIterator=(r,t)=>({[symbolAsyncIterator](){return this},async next(){const e=await r.next();if(e.done)return e;const n=t(e.value);return isPromise(n)?n.then(NextIteration):{value:n,done:!1}}}),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,t)=>function(e){return r(e,t)},curry2ResolveArg1=(r,t)=>function(e){return r(t,e)},curry2=function(r,t,e){return t==__?curry2ResolveArg0(r,e):curry2ResolveArg1(r,t)},curry3ResolveArg0=(r,t,e)=>function(n){return r(n,t,e)},curry3ResolveArg1=(r,t,e)=>function(n){return r(t,n,e)},curry3ResolveArg2=(r,t,e)=>function(n){return r(t,e,n)},curry3=function(r,t,e,n){return t==__?curry3ResolveArg0(r,e,n):e==__?curry3ResolveArg1(r,t,n):curry3ResolveArg2(r,t,e)},isArray=Array.isArray,isObject=r=>{if(null==r)return!1;const t=typeof r;return"object"==t||"function"==t},promiseAll=Promise.all.bind(Promise),arrayMap=function(r,t){const e=r.length,n=Array(e);let o=-1,s=!1;for(;++o<e;){const e=t(r[o],o,r);isPromise(e)&&(s=!0),n[o]=e}return s?promiseAll(n):n},callPropUnary=(r,t,e)=>r[t](e),stringMap=function(r,t){const e=arrayMap(r,t);return isPromise(e)?e.then(curry3(callPropUnary,__,"join","")):e.join("")},always=r=>function(){return r},setMap=function(r,t){const e=new Set,n=[];for(const o of r){const s=t(o,o,r);isPromise(s)?n.push(s.then(curry3(callPropUnary,e,"add",__))):e.add(s)}return 0==n.length?e:promiseAll(n).then(always(e))},curry4ResolveArg0=(r,t,e,n)=>function(o){return r(o,t,e,n)},curry4ResolveArg1=(r,t,e,n)=>function(o){return r(t,o,e,n)},curry4ResolveArg2=(r,t,e,n)=>function(o){return r(t,e,o,n)},curry4ResolveArg3=(r,t,e,n)=>function(o){return r(t,e,n,o)},curry4=function(r,t,e,n,o){return t==__?curry4ResolveArg0(r,e,n,o):e==__?curry4ResolveArg1(r,t,n,o):n==__?curry4ResolveArg2(r,t,e,o):curry4ResolveArg3(r,t,e,n)},callPropBinary=(r,t,e,n)=>r[t](e,n),mapMap=function(r,t){const e=new Map,n=[];for(const[o,s]of r){const i=t(s,o,r);isPromise(i)?n.push(i.then(curry4(callPropBinary,e,"set",o,__))):e.set(o,i)}return 0==n.length?e:promiseAll(n).then(always(e))},promiseObjectAllExecutor=r=>function(t){const e={};let n=0;for(const o in r){const s=r[o];isPromise(s)?(n+=1,s.then((r=>function(o){e[r]=o,n-=1,0==n&&t(e)})(o))):e[o]=s}0==n&&t(e)},promiseObjectAll=r=>new Promise(promiseObjectAllExecutor(r)),objectMap=function(r,t){const e={};let n=!1;for(const o in r){const s=t(r[o],o,r);isPromise(s)&&(n=!0),e[o]=s}return n?promiseObjectAll(e):e},objectSet=function(r,t,e){return r[t]=e,r},arrayMapSeriesAsync=async function(r,t,e,n){const o=r.length;for(;++n<o;){const o=t(r[n],n);e[n]=isPromise(o)?await o:o}return e},arrayMapSeries=function(r,t){const e=r.length,n=Array(e);let o=-1;for(;++o<e;){const e=t(r[o],o);if(isPromise(e))return e.then(funcConcat(curry3(objectSet,n,o,__),curry4(arrayMapSeriesAsync,r,t,__,o)));n[o]=e}return n},stringMapSeries=function(r,t){const e=arrayMapSeries(r,t);return isPromise(e)?e.then(curry3(callPropUnary,__,"join","")):e.join("")},thunkify4=(r,t,e,n,o)=>function(){return r(t,e,n,o)},_objectMapSeriesAsync=async function(r,t,e,n){for(const o in r){if(o in n)continue;let s=t(r[o]);isPromise(s)&&(s=await s),e[o]=s}return e},objectMapSeries=function(r,t){const e={},n={};for(const o in r){n[o]=!0;const s=t(r[o],o,r);if(isPromise(s))return s.then(funcConcat(curry3(objectSet,e,o,__),thunkify4(_objectMapSeriesAsync,r,t,e,n)));e[o]=s}return e},thunkify3=(r,t,e,n)=>function(){return r(t,e,n)},setAdd=function(r,t){return r.add(t),r},_setMapSeriesAsync=async function(r,t,e){let n=r.next();for(;!n.done;){let o=t(n.value);isPromise(o)&&(o=await o),e.add(o),n=r.next()}return e},setMapSeries=function(r,t){const e=new Set,n=r[symbolIterator]();let o=n.next();for(;!o.done;){const r=t(o.value);if(isPromise(r))return r.then(funcConcat(curry2(setAdd,e,__),thunkify3(_setMapSeriesAsync,n,t,e)));e.add(r),o=n.next()}return e},mapSet=function(r,t,e){return r.set(t,e)},_mapMapSeriesAsync=async function(r,t,e){let n=r.next();for(;!n.done;){let o=t(n.value[1]);isPromise(o)&&(o=await o),e.set(n.value[0],o),n=r.next()}return e},mapMapSeries=function(r,t){const e=new Map,n=r[symbolIterator]();let o=n.next();for(;!o.done;){const r=o.value[0],s=t(o.value[1]);if(isPromise(s))return s.then(funcConcat(curry3(mapSet,e,r,__),thunkify3(_mapMapSeriesAsync,n,t,e)));e.set(r,s),o=n.next()}return e},tapSync=r=>function(...t){return r(...t),t[0]},promiseRace=Promise.race.bind(Promise),arrayMapPoolAsync=async function(r,t,e,n,o,s){const i=r.length;for(;++o<i;){s.size>=e&&await promiseRace(s);const i=t(r[o]);if(isPromise(i)){const r=i.then(tapSync((()=>s.delete(r))));s.add(r),n[o]=r}else n[o]=i}return promiseAll(n)},arrayMapPool=function(r,t,e){const n=r.length,o=Array(n);let s=-1;for(;++s<n;){const n=e(r[s]);if(isPromise(n)){const i=new Set,c=n.then(tapSync((()=>i.delete(c))));return i.add(c),o[s]=c,arrayMapPoolAsync(r,e,t,o,s,i)}o[s]=n}return o},stringMapPool=function(r,t,e){const n=arrayMapPool(r,t,e);return isPromise(n)?n.then(curry3(callPropUnary,__,"join","")):n.join("")},_setMapPoolAsync=async function(r,t,e,n,o,s){let i=t.next();for(;!i.done;){s.size>=e&&await promiseRace(s);const c=n(i.value,i.value,r);if(isPromise(c)){const r=c.then((t=>{s.delete(r),o.add(t)}));s.add(r)}else o.add(c);i=t.next()}return s.size>0&&await promiseAll(s),o},setMapPool=function(r,t,e){const n=new Set,o=r[symbolIterator]();let s=o.next();for(;!s.done;){const i=e(s.value,s.value,r);if(isPromise(i)){const s=new Set,c=i.then((r=>{s.delete(c),n.add(r)}));return s.add(c),_setMapPoolAsync(r,o,t,e,n,s)}n.add(i),s=o.next()}return n},_mapMapPoolAsync=async function(r,t,e,n,o,s){let i=t.next();for(;!i.done;){s.size>=e&&await promiseRace(s);const c=i.value[0],a=n(i.value[1],c,r);if(isPromise(a)){o.set(c,a);const r=a.then((t=>{s.delete(r),o.set(c,t)}));s.add(r)}else o.set(c,a);i=t.next()}return s.size>0&&await promiseAll(s),o},mapMapPool=function(r,t,e){const n=new Map,o=r[symbolIterator]();let s=o.next();for(;!s.done;){const i=s.value[0],c=e(s.value[1],i,r);if(isPromise(c)){const s=new Set;n.set(i,c);const a=c.then((r=>{s.delete(a),n.set(i,r)}));return s.add(a),_mapMapPoolAsync(r,o,t,e,n,s)}n.set(i,c),s=o.next()}return n},_objectMapPoolAsync=async function(r,t,e,n,o,s){for(const i in r){if(i in o)continue;s.size>=t&&await promiseRace(s);const c=e(r[i],i,r);if(isPromise(c)){n[i]=c;const r=c.then((t=>{s.delete(r),n[i]=t}));s.add(r)}else n[i]=c}return s.size>0&&await promiseAll(s),n},objectMapPool=function(r,t,e){const n={},o={};for(const s in r){o[s]=!0;const i=e(r[s],s,r);if(isPromise(i)){const c=new Set;n[s]=i;const a=i.then((r=>{c.delete(a),n[s]=r}));return c.add(a),_objectMapPoolAsync(r,t,e,n,o,c)}n[s]=i}return n},_curryArity=(r,t,e)=>function(...n){const o=e.length,s=n.length,i=[];let c=-1,a=-1,u=0;for(;++c<o;){const o=e[c];if(o==__&&(a+=1)<s){const r=n[a];r==__&&(u+=1),i.push(r)}else i.push(o);if(i.length==r)return 0==u?t(...i):curryArity(r,t,i)}for(;++a<s;){const e=n[a];if(e==__&&(u+=1),i.push(e),i.length==r)return 0==u?t(...i):curryArity(r,t,i)}return curryArity(r,t,i)},curryArity=function(r,t,e){const n=e.length;if(n<r)return _curryArity(r,t,e);let o=-1;for(;++o<n;){if(e[o]==__)return _curryArity(r,t,e)}return t(...e)},spread2=r=>function([t,e]){return r(t,e)},objectMapEntries=function(r,t){const e={},n=[];for(const o in r){const s=t([o,r[o]]);isPromise(s)?n.push(s.then(spread2(curryArity(3,objectSet,[e])))):e[s[0]]=s[1]}return 0==n.length?e:promiseAll(n).then(always(e))},mapMapEntriesForEachCallback=(r,t,e)=>function(n,o){const s=r([o,n]);isPromise(s)?e.push(s.then(spread2(curryArity(3,mapSet,[t])))):t.set(s[0],s[1])},mapMapEntries=function(r,t){const e=new Map,n=[];return r.forEach(mapMapEntriesForEachCallback(t,e,n)),0==n.length?e:promiseAll(n).then(always(e))},_map=function(r,t){return isArray(r)?arrayMap(r,t):null==r?r:"function"==typeof r.then?r.then(t):"function"==typeof r.map?r.map(t):"string"==typeof r||r.constructor==String?stringMap(r,t):r.constructor==Set?setMap(r,t):r.constructor==Map?mapMap(r,t):"function"==typeof r[symbolIterator]?MappingIterator(r[symbolIterator](),t):"function"==typeof r[symbolAsyncIterator]?MappingAsyncIterator(r[symbolAsyncIterator](),t):r.constructor==Object?objectMap(r,t):t(r)},map=function(r,t){return null==t?curry2(_map,__,r):isPromise(r)?r.then(curry2(_map,__,t)):_map(r,t)},_mapEntries=(r,t)=>{if(null==r)throw new TypeError("value is not an Object or Map");if(r.constructor==Object)return objectMapEntries(r,t);if(r.constructor==Map)return mapMapEntries(r,t);throw new TypeError("value is not an Object or Map")};map.entries=function(r,t){return null==t?curry2(_mapEntries,__,r):isPromise(r)?r.then(curry2(_mapEntries,__,t)):_mapEntries(r,t)};const _mapSeries=function(r,t){if(isArray(r))return arrayMapSeries(r,t);if(null==r)throw new TypeError(`invalid collection ${r}`);if("string"==typeof r||r.constructor==String)return stringMapSeries(r,t);if(r.constructor==Set)return setMapSeries(r,t);if(r.constructor==Map)return mapMapSeries(r,t);if(r.constructor==Object)return objectMapSeries(r,t);throw new TypeError(`invalid collection ${r}`)};map.series=function(r,t){return null==t?curry2(_mapSeries,__,r):isPromise(r)?r.then(curry2(_mapSeries,__,t)):_mapSeries(r,t)};const _mapPool=function(r,t,e){if(isArray(r))return arrayMapPool(r,t,e);if(null==r)throw new TypeError(`invalid collection ${r}`);if("string"==typeof r||r.constructor==String)return stringMapPool(r,t,e);if(r.constructor==Set)return setMapPool(r,t,e);if(r.constructor==Map)return mapMapPool(r,t,e);if(r.constructor==Object)return objectMapPool(r,t,e);throw new TypeError(`invalid collection ${r}`)};map.pool=function(r,t,e){return null==e?curry3(_mapPool,__,r,t):isPromise(r)?r.then(curry3(_mapPool,__,t,e)):_mapPool(r,t,e)};const memoizeCappedUnary=function(r,t){const e=new Map,n=function(n){if(e.has(n))return e.get(n);const o=r(n);return e.set(n,o),e.size>t&&e.clear(),o};return n.cache=e,n},pathDelimiters=/[.|[|\]]+/,parsePropertyPath=function(r){const t=r.length-1,e="["==r[0],n="]"==r[t];return e&&n?r.slice(1,t).split(pathDelimiters):e?r.slice(1).split(pathDelimiters):n?r.slice(0,t).split(pathDelimiters):r.split(pathDelimiters)},memoizedCappedParsePropertyPath=memoizeCappedUnary(parsePropertyPath,500),propertyPathToArray=r=>isArray(r)?r:"string"==typeof r?memoizedCappedParsePropertyPath(r):[r],getByPath=function(r,t){const e=propertyPathToArray(t),n=e.length;let o=-1,s=r;for(;++o<n;)if(s=s[e[o]],null==s)return;return s},_get=function(r,t,e){const n=null==r?void 0:getByPath(r,t);return void 0===n?"function"==typeof e?e(r):e:n},get=function(r,t,e){return"string"==typeof r||"number"==typeof r||isArray(r)?curry3(_get,__,r,t):isPromise(r)?r.then(curry3(_get,__,t,e)):_get(r,t,e)},pluck=function(...r){const t=r.pop(),e=get(t);return 0==r.length?map(e):map(r[0],e)};export default pluck;
|