rubico 2.5.0 → 2.6.1
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/_internal/arrayMapPool.js +11 -19
- package/_internal/mapMapPool.js +80 -0
- package/_internal/objectMapPool.js +77 -0
- package/_internal/objectMapSeries.js +1 -0
- package/_internal/setMapPool.js +79 -0
- package/_internal/stringMapPool.js +22 -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 +3 -2
- package/dist/forEach.es.min.js +2 -2
- package/dist/forEach.js +3 -2
- package/dist/forEach.min.js +2 -2
- package/dist/forEach.mjs +3 -2
- 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 +221 -44
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +221 -44
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +221 -44
- 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 +259 -60
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +259 -60
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +259 -60
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +259 -60
- 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 +100 -14
- package/dist/tap.es.min.js +2 -2
- package/dist/tap.js +100 -14
- package/dist/tap.min.js +2 -2
- package/dist/tap.mjs +100 -14
- 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 +221 -44
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +221 -44
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +221 -44
- 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 +100 -14
- package/dist/x/trace.es.min.js +2 -2
- package/dist/x/trace.js +100 -14
- package/dist/x/trace.min.js +2 -2
- package/dist/x/trace.mjs +100 -14
- 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 +259 -60
- package/every.js +6 -0
- package/filter.js +9 -0
- package/flatMap.js +7 -0
- package/forEach.js +20 -1
- package/get.js +6 -0
- package/gt.js +6 -0
- package/gte.js +6 -0
- package/index.js +259 -60
- package/lt.js +6 -0
- package/lte.js +6 -0
- package/map.js +118 -45
- 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 +75 -26
- package/transform.js +38 -10
- package/tryCatch.js +14 -0
package/dist/map.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.
|
|
2
|
+
* rubico v2.6.1
|
|
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.
|
|
@@ -65,35 +65,6 @@ const curry2 = function (baseFunc, arg0, arg1) {
|
|
|
65
65
|
: curry2ResolveArg1(baseFunc, arg0)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const isArray = Array.isArray
|
|
69
|
-
|
|
70
|
-
const isObject = value => {
|
|
71
|
-
if (value == null) {
|
|
72
|
-
return false
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const typeofValue = typeof value
|
|
76
|
-
return (typeofValue == 'object') || (typeofValue == 'function')
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const promiseAll = Promise.all.bind(Promise)
|
|
80
|
-
|
|
81
|
-
const arrayMap = function (array, mapper) {
|
|
82
|
-
const arrayLength = array.length,
|
|
83
|
-
result = Array(arrayLength)
|
|
84
|
-
let index = -1,
|
|
85
|
-
isAsync = false
|
|
86
|
-
|
|
87
|
-
while (++index < arrayLength) {
|
|
88
|
-
const resultItem = mapper(array[index], index, array)
|
|
89
|
-
if (isPromise(resultItem)) {
|
|
90
|
-
isAsync = true
|
|
91
|
-
}
|
|
92
|
-
result[index] = resultItem
|
|
93
|
-
}
|
|
94
|
-
return isAsync ? promiseAll(result) : result
|
|
95
|
-
}
|
|
96
|
-
|
|
97
68
|
// argument resolver for curry3
|
|
98
69
|
const curry3ResolveArg0 = (
|
|
99
70
|
baseFunc, arg1, arg2,
|
|
@@ -125,6 +96,35 @@ const curry3 = function (baseFunc, arg0, arg1, arg2) {
|
|
|
125
96
|
return curry3ResolveArg2(baseFunc, arg0, arg1)
|
|
126
97
|
}
|
|
127
98
|
|
|
99
|
+
const isArray = Array.isArray
|
|
100
|
+
|
|
101
|
+
const isObject = value => {
|
|
102
|
+
if (value == null) {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const typeofValue = typeof value
|
|
107
|
+
return (typeofValue == 'object') || (typeofValue == 'function')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const promiseAll = Promise.all.bind(Promise)
|
|
111
|
+
|
|
112
|
+
const arrayMap = function (array, mapper) {
|
|
113
|
+
const arrayLength = array.length,
|
|
114
|
+
result = Array(arrayLength)
|
|
115
|
+
let index = -1,
|
|
116
|
+
isAsync = false
|
|
117
|
+
|
|
118
|
+
while (++index < arrayLength) {
|
|
119
|
+
const resultItem = mapper(array[index], index, array)
|
|
120
|
+
if (isPromise(resultItem)) {
|
|
121
|
+
isAsync = true
|
|
122
|
+
}
|
|
123
|
+
result[index] = resultItem
|
|
124
|
+
}
|
|
125
|
+
return isAsync ? promiseAll(result) : result
|
|
126
|
+
}
|
|
127
|
+
|
|
128
128
|
const callPropUnary = (value, property, arg0) => value[property](arg0)
|
|
129
129
|
|
|
130
130
|
const stringMap = function (string, mapper) {
|
|
@@ -335,6 +335,7 @@ const objectMapSeries = function (object, f) {
|
|
|
335
335
|
thunkify4(_objectMapSeriesAsync, object, f, result, doneKeys),
|
|
336
336
|
))
|
|
337
337
|
}
|
|
338
|
+
result[key] = resultItem
|
|
338
339
|
}
|
|
339
340
|
return result
|
|
340
341
|
}
|
|
@@ -433,15 +434,14 @@ const tapSync = func => function tapping(...args) {
|
|
|
433
434
|
const promiseRace = Promise.race.bind(Promise)
|
|
434
435
|
|
|
435
436
|
const arrayMapPoolAsync = async function (
|
|
436
|
-
array,
|
|
437
|
+
array, f, concurrencyLimit, result, index, promises,
|
|
437
438
|
) {
|
|
438
439
|
const arrayLength = array.length
|
|
439
440
|
while (++index < arrayLength) {
|
|
440
441
|
if (promises.size >= concurrencyLimit) {
|
|
441
442
|
await promiseRace(promises)
|
|
442
443
|
}
|
|
443
|
-
|
|
444
|
-
const resultItem = mapper(array[index])
|
|
444
|
+
const resultItem = f(array[index])
|
|
445
445
|
if (isPromise(resultItem)) {
|
|
446
446
|
const selfDeletingPromise = resultItem.then(
|
|
447
447
|
tapSync(() => promises.delete(selfDeletingPromise)))
|
|
@@ -454,13 +454,12 @@ const arrayMapPoolAsync = async function (
|
|
|
454
454
|
return promiseAll(result)
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
const arrayMapPool = function (array,
|
|
457
|
+
const arrayMapPool = function (array, concurrency, f) {
|
|
458
458
|
const arrayLength = array.length,
|
|
459
459
|
result = Array(arrayLength)
|
|
460
460
|
let index = -1
|
|
461
461
|
while (++index < arrayLength) {
|
|
462
|
-
|
|
463
|
-
const resultItem = mapper(array[index])
|
|
462
|
+
const resultItem = f(array[index])
|
|
464
463
|
if (isPromise(resultItem)) {
|
|
465
464
|
const promises = new Set(),
|
|
466
465
|
selfDeletingPromise = resultItem.then(
|
|
@@ -468,13 +467,167 @@ const arrayMapPool = function (array, mapper, concurrentLimit) {
|
|
|
468
467
|
promises.add(selfDeletingPromise)
|
|
469
468
|
result[index] = selfDeletingPromise
|
|
470
469
|
return arrayMapPoolAsync(
|
|
471
|
-
array,
|
|
470
|
+
array, f, concurrency, result, index, promises)
|
|
472
471
|
}
|
|
473
472
|
result[index] = resultItem
|
|
474
473
|
}
|
|
475
474
|
return result
|
|
476
475
|
}
|
|
477
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
|
+
|
|
478
631
|
const _curryArity = (arity, func, args) => function curried(...curriedArgs) {
|
|
479
632
|
const argsLength = args.length,
|
|
480
633
|
curriedArgsLength = curriedArgs.length,
|
|
@@ -610,7 +763,7 @@ const _map = function (value, mapper) {
|
|
|
610
763
|
}
|
|
611
764
|
|
|
612
765
|
const map = function (arg0, arg1) {
|
|
613
|
-
if (
|
|
766
|
+
if (arg1 == null) {
|
|
614
767
|
return curry2(_map, __, arg0)
|
|
615
768
|
}
|
|
616
769
|
return isPromise(arg0)
|
|
@@ -633,7 +786,7 @@ const _mapEntries = (value, mapper) => {
|
|
|
633
786
|
}
|
|
634
787
|
|
|
635
788
|
map.entries = function mapEntries(arg0, arg1) {
|
|
636
|
-
if (
|
|
789
|
+
if (arg1 == null) {
|
|
637
790
|
return curry2(_mapEntries, __, arg0)
|
|
638
791
|
}
|
|
639
792
|
return isPromise(arg0)
|
|
@@ -665,7 +818,7 @@ const _mapSeries = function (collection, f) {
|
|
|
665
818
|
}
|
|
666
819
|
|
|
667
820
|
map.series = function mapSeries(arg0, arg1) {
|
|
668
|
-
if (
|
|
821
|
+
if (arg1 == null) {
|
|
669
822
|
return curry2(_mapSeries, __, arg0)
|
|
670
823
|
}
|
|
671
824
|
return isPromise(arg0)
|
|
@@ -673,11 +826,35 @@ map.series = function mapSeries(arg0, arg1) {
|
|
|
673
826
|
: _mapSeries(arg0, arg1)
|
|
674
827
|
}
|
|
675
828
|
|
|
676
|
-
|
|
677
|
-
if (isArray(
|
|
678
|
-
return arrayMapPool(
|
|
829
|
+
const _mapPool = function (collection, concurrency, f) {
|
|
830
|
+
if (isArray(collection)) {
|
|
831
|
+
return arrayMapPool(collection, concurrency, f)
|
|
679
832
|
}
|
|
680
|
-
|
|
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)
|
|
681
858
|
}
|
|
682
859
|
|
|
683
860
|
export default map
|
package/dist/map.es.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.
|
|
2
|
+
* rubico v2.6.1
|
|
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,symbolIterator=Symbol.iterator,MappingIterator=(r,t)=>({toString:()=>"[object MappingIterator]",[symbolIterator](){return this},next(){const n=r.next();return n.done?n:{value:t(n.value),done:!1}}}),NextIteration=r=>({value:r,done:!1}),symbolAsyncIterator=Symbol.asyncIterator,MappingAsyncIterator=(r,t)=>({[symbolAsyncIterator](){return this},async next(){const n=await r.next();if(n.done)return n;const e=t(n.value);return isPromise(e)?e.then(NextIteration):{value:e,done:!1}}}),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,t)=>function(n){return r(n,t)},curry2ResolveArg1=(r,t)=>function(n){return r(t,n)},curry2=function(r,t,n){return t==__?curry2ResolveArg0(r,n):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 n=r.length,e=Array(n);let o=-1,s=!1;for(;++o<n;){const n=t(r[o],o,r);isPromise(n)&&(s=!0),e[o]=n}return s?promiseAll(e):e},curry3ResolveArg0=(r,t,n)=>function(e){return r(e,t,n)},curry3ResolveArg1=(r,t,n)=>function(e){return r(t,e,n)},curry3ResolveArg2=(r,t,n)=>function(e){return r(t,n,e)},curry3=function(r,t,n,e){return t==__?curry3ResolveArg0(r,n,e):n==__?curry3ResolveArg1(r,t,e):curry3ResolveArg2(r,t,n)},callPropUnary=(r,t,n)=>r[t](n),stringMap=function(r,t){const n=arrayMap(r,t);return isPromise(n)?n.then(curry3(callPropUnary,__,"join","")):n.join("")},always=r=>function(){return r},setMap=function(r,t){const n=new Set,e=[];for(const o of r){const s=t(o,o,r);isPromise(s)?e.push(s.then(curry3(callPropUnary,n,"add",__))):n.add(s)}return 0==e.length?n:promiseAll(e).then(always(n))},curry4ResolveArg0=(r,t,n,e)=>function(o){return r(o,t,n,e)},curry4ResolveArg1=(r,t,n,e)=>function(o){return r(t,o,n,e)},curry4ResolveArg2=(r,t,n,e)=>function(o){return r(t,n,o,e)},curry4ResolveArg3=(r,t,n,e)=>function(o){return r(t,n,e,o)},curry4=function(r,t,n,e,o){return t==__?curry4ResolveArg0(r,n,e,o):n==__?curry4ResolveArg1(r,t,e,o):e==__?curry4ResolveArg2(r,t,n,o):curry4ResolveArg3(r,t,n,e)},callPropBinary=(r,t,n,e)=>r[t](n,e),mapMap=function(r,t){const n=new Map,e=[];for(const[o,s]of r){const c=t(s,o,r);isPromise(c)?e.push(c.then(curry4(callPropBinary,n,"set",o,__))):n.set(o,c)}return 0==e.length?n:promiseAll(e).then(always(n))},promiseObjectAllExecutor=r=>function(t){const n={};let e=0;for(const o in r){const s=r[o];isPromise(s)?(e+=1,s.then((r=>function(o){n[r]=o,e-=1,0==e&&t(n)})(o))):n[o]=s}0==e&&t(n)},promiseObjectAll=r=>new Promise(promiseObjectAllExecutor(r)),objectMap=function(r,t){const n={};let e=!1;for(const o in r){const s=t(r[o],o,r);isPromise(s)&&(e=!0),n[o]=s}return e?promiseObjectAll(n):n},funcConcat=(r,t)=>function(...n){const e=r(...n);return isPromise(e)?e.then(t):t(e)},objectSet=function(r,t,n){return r[t]=n,r},arrayMapSeriesAsync=async function(r,t,n,e){const o=r.length;for(;++e<o;){const o=t(r[e],e);n[e]=isPromise(o)?await o:o}return n},arrayMapSeries=function(r,t){const n=r.length,e=Array(n);let o=-1;for(;++o<n;){const n=t(r[o],o);if(isPromise(n))return n.then(funcConcat(curry3(objectSet,e,o,__),curry4(arrayMapSeriesAsync,r,t,__,o)));e[o]=n}return e},stringMapSeries=function(r,t){const n=arrayMapSeries(r,t);return isPromise(n)?n.then(curry3(callPropUnary,__,"join","")):n.join("")},thunkify4=(r,t,n,e,o)=>function(){return r(t,n,e,o)},_objectMapSeriesAsync=async function(r,t,n,e){for(const o in r){if(o in e)continue;let s=t(r[o]);isPromise(s)&&(s=await s),n[o]=s}return n},objectMapSeries=function(r,t){const n={},e={};for(const o in r){e[o]=!0;const s=t(r[o],o,r);if(isPromise(s))return s.then(funcConcat(curry3(objectSet,n,o,__),thunkify4(_objectMapSeriesAsync,r,t,n,e)))}return n},thunkify3=(r,t,n,e)=>function(){return r(t,n,e)},setAdd=function(r,t){return r.add(t),r},_setMapSeriesAsync=async function(r,t,n){let e=r.next();for(;!e.done;){let o=t(e.value);isPromise(o)&&(o=await o),n.add(o),e=r.next()}return n},setMapSeries=function(r,t){const n=new Set,e=r[symbolIterator]();let o=e.next();for(;!o.done;){const r=t(o.value);if(isPromise(r))return r.then(funcConcat(curry2(setAdd,n,__),thunkify3(_setMapSeriesAsync,e,t,n)));n.add(r),o=e.next()}return n},mapSet=function(r,t,n){return r.set(t,n)},_mapMapSeriesAsync=async function(r,t,n){let e=r.next();for(;!e.done;){let o=t(e.value[1]);isPromise(o)&&(o=await o),n.set(e.value[0],o),e=r.next()}return n},mapMapSeries=function(r,t){const n=new Map,e=r[symbolIterator]();let o=e.next();for(;!o.done;){const r=o.value[0],s=t(o.value[1]);if(isPromise(s))return s.then(funcConcat(curry3(mapSet,n,r,__),thunkify3(_mapMapSeriesAsync,e,t,n)));n.set(r,s),o=e.next()}return n},tapSync=r=>function(...t){return r(...t),t[0]},promiseRace=Promise.race.bind(Promise),arrayMapPoolAsync=async function(r,t,n,e,o,s){const c=r.length;for(;++o<c;){s.size>=n&&await promiseRace(s);const c=t(r[o]);if(isPromise(c)){const r=c.then(tapSync((()=>s.delete(r))));s.add(r),e[o]=r}else e[o]=c}return promiseAll(e)},arrayMapPool=function(r,t,n){const e=r.length,o=Array(e);let s=-1;for(;++s<e;){const e=t(r[s]);if(isPromise(e)){const c=new Set,i=e.then(tapSync((()=>c.delete(i))));return c.add(i),o[s]=i,arrayMapPoolAsync(r,t,n,o,s,c)}o[s]=e}return o},_curryArity=(r,t,n)=>function(...e){const o=n.length,s=e.length,c=[];let i=-1,a=-1,u=0;for(;++i<o;){const o=n[i];if(o==__&&(a+=1)<s){const r=e[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 n=e[a];if(n==__&&(u+=1),c.push(n),c.length==r)return 0==u?t(...c):curryArity(r,t,c)}return curryArity(r,t,c)},curryArity=function(r,t,n){const e=n.length;if(e<r)return _curryArity(r,t,n);let o=-1;for(;++o<e;){if(n[o]==__)return _curryArity(r,t,n)}return t(...n)},spread2=r=>function([t,n]){return r(t,n)},objectMapEntries=function(r,t){const n={},e=[];for(const o in r){const s=t([o,r[o]]);isPromise(s)?e.push(s.then(spread2(curryArity(3,objectSet,[n])))):n[s[0]]=s[1]}return 0==e.length?n:promiseAll(e).then(always(n))},mapMapEntriesForEachCallback=(r,t,n)=>function(e,o){const s=r([o,e]);isPromise(s)?n.push(s.then(spread2(curryArity(3,mapSet,[t])))):t.set(s[0],s[1])},mapMapEntries=function(r,t){const n=new Map,e=[];return r.forEach(mapMapEntriesForEachCallback(t,n,e)),0==e.length?n:promiseAll(e).then(always(n))},_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)};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"function"==typeof r?curry2(_mapSeries,__,r):isPromise(r)?r.then(curry2(_mapSeries,__,t)):_mapSeries(r,t)},map.pool=(r,t)=>function(n){if(isArray(n))return arrayMapPool(n,t,r);throw new TypeError(`${n} is not an Array`)};export default map;
|
|
7
|
+
const isPromise=r=>null!=r&&"function"==typeof r.then,symbolIterator=Symbol.iterator,MappingIterator=(r,e)=>({toString:()=>"[object MappingIterator]",[symbolIterator](){return this},next(){const t=r.next();return t.done?t:{value:e(t.value),done:!1}}}),NextIteration=r=>({value:r,done:!1}),symbolAsyncIterator=Symbol.asyncIterator,MappingAsyncIterator=(r,e)=>({[symbolAsyncIterator](){return this},async next(){const t=await r.next();if(t.done)return t;const n=e(t.value);return isPromise(n)?n.then(NextIteration):{value:n,done:!1}}}),__=Symbol.for("placeholder"),curry2ResolveArg0=(r,e)=>function(t){return r(t,e)},curry2ResolveArg1=(r,e)=>function(t){return r(e,t)},curry2=function(r,e,t){return e==__?curry2ResolveArg0(r,t):curry2ResolveArg1(r,e)},curry3ResolveArg0=(r,e,t)=>function(n){return r(n,e,t)},curry3ResolveArg1=(r,e,t)=>function(n){return r(e,n,t)},curry3ResolveArg2=(r,e,t)=>function(n){return r(e,t,n)},curry3=function(r,e,t,n){return e==__?curry3ResolveArg0(r,t,n):t==__?curry3ResolveArg1(r,e,n):curry3ResolveArg2(r,e,t)},isArray=Array.isArray,isObject=r=>{if(null==r)return!1;const e=typeof r;return"object"==e||"function"==e},promiseAll=Promise.all.bind(Promise),arrayMap=function(r,e){const t=r.length,n=Array(t);let o=-1,s=!1;for(;++o<t;){const t=e(r[o],o,r);isPromise(t)&&(s=!0),n[o]=t}return s?promiseAll(n):n},callPropUnary=(r,e,t)=>r[e](t),stringMap=function(r,e){const t=arrayMap(r,e);return isPromise(t)?t.then(curry3(callPropUnary,__,"join","")):t.join("")},always=r=>function(){return r},setMap=function(r,e){const t=new Set,n=[];for(const o of r){const s=e(o,o,r);isPromise(s)?n.push(s.then(curry3(callPropUnary,t,"add",__))):t.add(s)}return 0==n.length?t:promiseAll(n).then(always(t))},curry4ResolveArg0=(r,e,t,n)=>function(o){return r(o,e,t,n)},curry4ResolveArg1=(r,e,t,n)=>function(o){return r(e,o,t,n)},curry4ResolveArg2=(r,e,t,n)=>function(o){return r(e,t,o,n)},curry4ResolveArg3=(r,e,t,n)=>function(o){return r(e,t,n,o)},curry4=function(r,e,t,n,o){return e==__?curry4ResolveArg0(r,t,n,o):t==__?curry4ResolveArg1(r,e,n,o):n==__?curry4ResolveArg2(r,e,t,o):curry4ResolveArg3(r,e,t,n)},callPropBinary=(r,e,t,n)=>r[e](t,n),mapMap=function(r,e){const t=new Map,n=[];for(const[o,s]of r){const i=e(s,o,r);isPromise(i)?n.push(i.then(curry4(callPropBinary,t,"set",o,__))):t.set(o,i)}return 0==n.length?t:promiseAll(n).then(always(t))},promiseObjectAllExecutor=r=>function(e){const t={};let n=0;for(const o in r){const s=r[o];isPromise(s)?(n+=1,s.then((r=>function(o){t[r]=o,n-=1,0==n&&e(t)})(o))):t[o]=s}0==n&&e(t)},promiseObjectAll=r=>new Promise(promiseObjectAllExecutor(r)),objectMap=function(r,e){const t={};let n=!1;for(const o in r){const s=e(r[o],o,r);isPromise(s)&&(n=!0),t[o]=s}return n?promiseObjectAll(t):t},funcConcat=(r,e)=>function(...t){const n=r(...t);return isPromise(n)?n.then(e):e(n)},objectSet=function(r,e,t){return r[e]=t,r},arrayMapSeriesAsync=async function(r,e,t,n){const o=r.length;for(;++n<o;){const o=e(r[n],n);t[n]=isPromise(o)?await o:o}return t},arrayMapSeries=function(r,e){const t=r.length,n=Array(t);let o=-1;for(;++o<t;){const t=e(r[o],o);if(isPromise(t))return t.then(funcConcat(curry3(objectSet,n,o,__),curry4(arrayMapSeriesAsync,r,e,__,o)));n[o]=t}return n},stringMapSeries=function(r,e){const t=arrayMapSeries(r,e);return isPromise(t)?t.then(curry3(callPropUnary,__,"join","")):t.join("")},thunkify4=(r,e,t,n,o)=>function(){return r(e,t,n,o)},_objectMapSeriesAsync=async function(r,e,t,n){for(const o in r){if(o in n)continue;let s=e(r[o]);isPromise(s)&&(s=await s),t[o]=s}return t},objectMapSeries=function(r,e){const t={},n={};for(const o in r){n[o]=!0;const s=e(r[o],o,r);if(isPromise(s))return s.then(funcConcat(curry3(objectSet,t,o,__),thunkify4(_objectMapSeriesAsync,r,e,t,n)));t[o]=s}return t},thunkify3=(r,e,t,n)=>function(){return r(e,t,n)},setAdd=function(r,e){return r.add(e),r},_setMapSeriesAsync=async function(r,e,t){let n=r.next();for(;!n.done;){let o=e(n.value);isPromise(o)&&(o=await o),t.add(o),n=r.next()}return t},setMapSeries=function(r,e){const t=new Set,n=r[symbolIterator]();let o=n.next();for(;!o.done;){const r=e(o.value);if(isPromise(r))return r.then(funcConcat(curry2(setAdd,t,__),thunkify3(_setMapSeriesAsync,n,e,t)));t.add(r),o=n.next()}return t},mapSet=function(r,e,t){return r.set(e,t)},_mapMapSeriesAsync=async function(r,e,t){let n=r.next();for(;!n.done;){let o=e(n.value[1]);isPromise(o)&&(o=await o),t.set(n.value[0],o),n=r.next()}return t},mapMapSeries=function(r,e){const t=new Map,n=r[symbolIterator]();let o=n.next();for(;!o.done;){const r=o.value[0],s=e(o.value[1]);if(isPromise(s))return s.then(funcConcat(curry3(mapSet,t,r,__),thunkify3(_mapMapSeriesAsync,n,e,t)));t.set(r,s),o=n.next()}return t},tapSync=r=>function(...e){return r(...e),e[0]},promiseRace=Promise.race.bind(Promise),arrayMapPoolAsync=async function(r,e,t,n,o,s){const i=r.length;for(;++o<i;){s.size>=t&&await promiseRace(s);const i=e(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,e,t){const n=r.length,o=Array(n);let s=-1;for(;++s<n;){const n=t(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,t,e,o,s,i)}o[s]=n}return o},stringMapPool=function(r,e,t){const n=arrayMapPool(r,e,t);return isPromise(n)?n.then(curry3(callPropUnary,__,"join","")):n.join("")},_setMapPoolAsync=async function(r,e,t,n,o,s){let i=e.next();for(;!i.done;){s.size>=t&&await promiseRace(s);const c=n(i.value,i.value,r);if(isPromise(c)){const r=c.then((e=>{s.delete(r),o.add(e)}));s.add(r)}else o.add(c);i=e.next()}return s.size>0&&await promiseAll(s),o},setMapPool=function(r,e,t){const n=new Set,o=r[symbolIterator]();let s=o.next();for(;!s.done;){const i=t(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,e,t,n,s)}n.add(i),s=o.next()}return n},_mapMapPoolAsync=async function(r,e,t,n,o,s){let i=e.next();for(;!i.done;){s.size>=t&&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((e=>{s.delete(r),o.set(c,e)}));s.add(r)}else o.set(c,a);i=e.next()}return s.size>0&&await promiseAll(s),o},mapMapPool=function(r,e,t){const n=new Map,o=r[symbolIterator]();let s=o.next();for(;!s.done;){const i=s.value[0],c=t(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,e,t,n,s)}n.set(i,c),s=o.next()}return n},_objectMapPoolAsync=async function(r,e,t,n,o,s){for(const i in r){if(i in o)continue;s.size>=e&&await promiseRace(s);const c=t(r[i],i,r);if(isPromise(c)){n[i]=c;const r=c.then((e=>{s.delete(r),n[i]=e}));s.add(r)}else n[i]=c}return s.size>0&&await promiseAll(s),n},objectMapPool=function(r,e,t){const n={},o={};for(const s in r){o[s]=!0;const i=t(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,e,t,n,o,c)}n[s]=i}return n},_curryArity=(r,e,t)=>function(...n){const o=t.length,s=n.length,i=[];let c=-1,a=-1,u=0;for(;++c<o;){const o=t[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?e(...i):curryArity(r,e,i)}for(;++a<s;){const t=n[a];if(t==__&&(u+=1),i.push(t),i.length==r)return 0==u?e(...i):curryArity(r,e,i)}return curryArity(r,e,i)},curryArity=function(r,e,t){const n=t.length;if(n<r)return _curryArity(r,e,t);let o=-1;for(;++o<n;){if(t[o]==__)return _curryArity(r,e,t)}return e(...t)},spread2=r=>function([e,t]){return r(e,t)},objectMapEntries=function(r,e){const t={},n=[];for(const o in r){const s=e([o,r[o]]);isPromise(s)?n.push(s.then(spread2(curryArity(3,objectSet,[t])))):t[s[0]]=s[1]}return 0==n.length?t:promiseAll(n).then(always(t))},mapMapEntriesForEachCallback=(r,e,t)=>function(n,o){const s=r([o,n]);isPromise(s)?t.push(s.then(spread2(curryArity(3,mapSet,[e])))):e.set(s[0],s[1])},mapMapEntries=function(r,e){const t=new Map,n=[];return r.forEach(mapMapEntriesForEachCallback(e,t,n)),0==n.length?t:promiseAll(n).then(always(t))},_map=function(r,e){return isArray(r)?arrayMap(r,e):null==r?r:"function"==typeof r.then?r.then(e):"function"==typeof r.map?r.map(e):"string"==typeof r||r.constructor==String?stringMap(r,e):r.constructor==Set?setMap(r,e):r.constructor==Map?mapMap(r,e):"function"==typeof r[symbolIterator]?MappingIterator(r[symbolIterator](),e):"function"==typeof r[symbolAsyncIterator]?MappingAsyncIterator(r[symbolAsyncIterator](),e):r.constructor==Object?objectMap(r,e):e(r)},map=function(r,e){return null==e?curry2(_map,__,r):isPromise(r)?r.then(curry2(_map,__,e)):_map(r,e)},_mapEntries=(r,e)=>{if(null==r)throw new TypeError("value is not an Object or Map");if(r.constructor==Object)return objectMapEntries(r,e);if(r.constructor==Map)return mapMapEntries(r,e);throw new TypeError("value is not an Object or Map")};map.entries=function(r,e){return null==e?curry2(_mapEntries,__,r):isPromise(r)?r.then(curry2(_mapEntries,__,e)):_mapEntries(r,e)};const _mapSeries=function(r,e){if(isArray(r))return arrayMapSeries(r,e);if(null==r)throw new TypeError(`invalid collection ${r}`);if("string"==typeof r||r.constructor==String)return stringMapSeries(r,e);if(r.constructor==Set)return setMapSeries(r,e);if(r.constructor==Map)return mapMapSeries(r,e);if(r.constructor==Object)return objectMapSeries(r,e);throw new TypeError(`invalid collection ${r}`)};map.series=function(r,e){return null==e?curry2(_mapSeries,__,r):isPromise(r)?r.then(curry2(_mapSeries,__,e)):_mapSeries(r,e)};const _mapPool=function(r,e,t){if(isArray(r))return arrayMapPool(r,e,t);if(null==r)throw new TypeError(`invalid collection ${r}`);if("string"==typeof r||r.constructor==String)return stringMapPool(r,e,t);if(r.constructor==Set)return setMapPool(r,e,t);if(r.constructor==Map)return mapMapPool(r,e,t);if(r.constructor==Object)return objectMapPool(r,e,t);throw new TypeError(`invalid collection ${r}`)};map.pool=function(r,e,t){return null==t?curry3(_mapPool,__,r,e):isPromise(r)?r.then(curry3(_mapPool,__,e,t)):_mapPool(r,e,t)};export default map;
|