rubico 2.7.8 → 2.7.10
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 +2 -2
- package/_internal/arrayForEach.js +1 -1
- package/_internal/arrayForEachSeries.js +1 -1
- package/_internal/arraySome.js +6 -6
- package/_internal/asyncIteratorEvery.js +10 -10
- package/_internal/asyncIteratorSome.js +9 -9
- package/_internal/objectForEach.js +1 -1
- package/_internal/objectForEachSeries.js +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/eq.mjs +1 -1
- package/dist/every.es.js +9 -9
- package/dist/every.es.min.js +2 -2
- package/dist/every.js +9 -9
- package/dist/every.min.js +2 -2
- package/dist/every.mjs +9 -9
- 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 +2 -2
- package/dist/filter.mjs +1 -1
- package/dist/flatMap.es.js +1 -1
- package/dist/flatMap.es.min.js +2 -2
- package/dist/flatMap.js +1 -1
- package/dist/flatMap.min.js +2 -2
- package/dist/flatMap.mjs +1 -1
- package/dist/forEach.es.js +5 -5
- package/dist/forEach.es.min.js +2 -2
- package/dist/forEach.js +5 -5
- package/dist/forEach.min.js +2 -2
- package/dist/forEach.mjs +5 -5
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/lte.mjs +1 -1
- package/dist/map.es.js +1 -1
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +1 -1
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +1 -1
- package/dist/not.es.js +1 -1
- package/dist/not.es.min.js +1 -1
- package/dist/not.js +1 -1
- package/dist/not.min.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/reduce.mjs +1 -1
- package/dist/rubico.es.js +26 -26
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +26 -26
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +26 -26
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +26 -26
- 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 +2 -2
- package/dist/set.mjs +1 -1
- package/dist/some.es.js +14 -14
- package/dist/some.es.min.js +2 -2
- package/dist/some.js +14 -14
- package/dist/some.min.js +2 -2
- package/dist/some.mjs +14 -14
- 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 +2 -2
- package/dist/switchCase.mjs +1 -1
- package/dist/tap.es.js +1 -1
- package/dist/tap.es.min.js +1 -1
- package/dist/tap.js +1 -1
- package/dist/tap.min.js +2 -2
- package/dist/tap.mjs +1 -1
- package/dist/thunkify.es.js +1 -1
- package/dist/thunkify.es.min.js +1 -1
- package/dist/thunkify.js +1 -1
- package/dist/thunkify.min.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/x/defaultsDeep.mjs +1 -1
- package/dist/x/differenceWith.es.js +6 -6
- package/dist/x/differenceWith.es.min.js +2 -2
- package/dist/x/differenceWith.js +6 -6
- package/dist/x/differenceWith.min.js +2 -2
- package/dist/x/differenceWith.mjs +6 -6
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/x/first.mjs +1 -1
- package/dist/x/flatten.es.js +1 -1
- package/dist/x/flatten.es.min.js +2 -2
- package/dist/x/flatten.js +1 -1
- package/dist/x/flatten.min.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/x/noop.mjs +1 -1
- package/dist/x/pluck.es.js +1 -1
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +1 -1
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +1 -1
- package/dist/x/prepend.es.js +1 -1
- package/dist/x/prepend.es.min.js +1 -1
- package/dist/x/prepend.js +1 -1
- package/dist/x/prepend.min.js +2 -2
- 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 +2 -2
- package/dist/x/size.mjs +1 -1
- package/dist/x/trace.es.js +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +2 -2
- package/dist/x/trace.mjs +1 -1
- package/dist/x/unionWith.es.js +1 -1
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +1 -1
- package/dist/x/unionWith.min.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/x/when.mjs +1 -1
- package/es.js +26 -26
- package/index.js +26 -26
- package/package.json +2 -1
package/es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.7.
|
|
2
|
+
* rubico v2.7.10
|
|
3
3
|
* https://github.com/a-synchronous/rubico
|
|
4
4
|
* (c) 2019-2026 Richard Tong
|
|
5
5
|
* rubico may be freely distributed under the MIT license.
|
|
@@ -2258,7 +2258,7 @@ const arrayForEach = function (array, callback) {
|
|
|
2258
2258
|
promises = []
|
|
2259
2259
|
let index = -1
|
|
2260
2260
|
while (++index < length) {
|
|
2261
|
-
const operation = callback(array[index])
|
|
2261
|
+
const operation = callback(array[index], index, array)
|
|
2262
2262
|
if (isPromise(operation)) {
|
|
2263
2263
|
promises.push(operation)
|
|
2264
2264
|
}
|
|
@@ -2269,7 +2269,7 @@ const arrayForEach = function (array, callback) {
|
|
|
2269
2269
|
const objectForEach = function (object, callback) {
|
|
2270
2270
|
const promises = []
|
|
2271
2271
|
for (const key in object) {
|
|
2272
|
-
const operation = callback(object[key])
|
|
2272
|
+
const operation = callback(object[key], key, object)
|
|
2273
2273
|
if (isPromise(operation)) {
|
|
2274
2274
|
promises.push(operation)
|
|
2275
2275
|
}
|
|
@@ -2308,7 +2308,7 @@ const arrayForEachSeries = function (array, callback) {
|
|
|
2308
2308
|
const length = array.length
|
|
2309
2309
|
let index = -1
|
|
2310
2310
|
while (++index < length) {
|
|
2311
|
-
const operation = callback(array[index])
|
|
2311
|
+
const operation = callback(array[index], index, array)
|
|
2312
2312
|
if (isPromise(operation)) {
|
|
2313
2313
|
return operation
|
|
2314
2314
|
.then(thunkify3(_arrayForEachSeriesAsync, array, callback, index))
|
|
@@ -2339,7 +2339,7 @@ const objectForEachSeries = function (object, callback) {
|
|
|
2339
2339
|
const doneKeys = {}
|
|
2340
2340
|
for (const key in object) {
|
|
2341
2341
|
doneKeys[key] = true
|
|
2342
|
-
const operation = callback(object[key])
|
|
2342
|
+
const operation = callback(object[key], key, object)
|
|
2343
2343
|
if (isPromise(operation)) {
|
|
2344
2344
|
return operation
|
|
2345
2345
|
.then(thunkify3(_objectForEachSeriesAsync, object, callback, doneKeys))
|
|
@@ -2455,21 +2455,21 @@ const SelfReferencingPromise = function (basePromise) {
|
|
|
2455
2455
|
}
|
|
2456
2456
|
|
|
2457
2457
|
const asyncArraySome = async function (
|
|
2458
|
-
array, predicate, index,
|
|
2458
|
+
array, predicate, index, promises,
|
|
2459
2459
|
) {
|
|
2460
2460
|
const length = array.length
|
|
2461
2461
|
|
|
2462
2462
|
while (++index < length) {
|
|
2463
2463
|
const predication = predicate(array[index])
|
|
2464
2464
|
if (isPromise(predication)) {
|
|
2465
|
-
|
|
2465
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2466
2466
|
} else if (predication) {
|
|
2467
2467
|
return true
|
|
2468
2468
|
}
|
|
2469
2469
|
}
|
|
2470
|
-
while (
|
|
2471
|
-
const [predication, promise] = await promiseRace(
|
|
2472
|
-
|
|
2470
|
+
while (promises.size > 0) {
|
|
2471
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2472
|
+
promises.delete(promise)
|
|
2473
2473
|
if (predication) {
|
|
2474
2474
|
return true
|
|
2475
2475
|
}
|
|
@@ -2494,7 +2494,7 @@ const arraySome = function (array, predicate) {
|
|
|
2494
2494
|
}
|
|
2495
2495
|
|
|
2496
2496
|
const asyncIteratorSome = async function (
|
|
2497
|
-
iterator, predicate,
|
|
2497
|
+
iterator, predicate, promises, maxConcurrency = 20,
|
|
2498
2498
|
) {
|
|
2499
2499
|
let iteration = iterator.next()
|
|
2500
2500
|
if (isPromise(iteration)) {
|
|
@@ -2502,16 +2502,16 @@ const asyncIteratorSome = async function (
|
|
|
2502
2502
|
}
|
|
2503
2503
|
|
|
2504
2504
|
while (!iteration.done) {
|
|
2505
|
-
if (
|
|
2506
|
-
const [predication, promise] = await promiseRace(
|
|
2507
|
-
|
|
2505
|
+
if (promises.size >= maxConcurrency) {
|
|
2506
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2507
|
+
promises.delete(promise)
|
|
2508
2508
|
if (predication) {
|
|
2509
2509
|
return true
|
|
2510
2510
|
}
|
|
2511
2511
|
}
|
|
2512
2512
|
const predication = predicate(iteration.value)
|
|
2513
2513
|
if (isPromise(predication)) {
|
|
2514
|
-
|
|
2514
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2515
2515
|
} else if (predication) {
|
|
2516
2516
|
return true
|
|
2517
2517
|
}
|
|
@@ -2520,9 +2520,9 @@ const asyncIteratorSome = async function (
|
|
|
2520
2520
|
iteration = await iteration
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
|
-
while (
|
|
2524
|
-
const [predication, promise] = await promiseRace(
|
|
2525
|
-
|
|
2523
|
+
while (promises.size > 0) {
|
|
2524
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2525
|
+
promises.delete(promise)
|
|
2526
2526
|
if (predication) {
|
|
2527
2527
|
return true
|
|
2528
2528
|
}
|
|
@@ -2621,13 +2621,13 @@ const iteratorEvery = function (iterator, predicate) {
|
|
|
2621
2621
|
}
|
|
2622
2622
|
|
|
2623
2623
|
const asyncIteratorEvery = async function (
|
|
2624
|
-
asyncIterator, predicate,
|
|
2624
|
+
asyncIterator, predicate, promises, maxConcurrency = 20,
|
|
2625
2625
|
) {
|
|
2626
2626
|
let iteration = await asyncIterator.next()
|
|
2627
2627
|
while (!iteration.done) {
|
|
2628
|
-
if (
|
|
2629
|
-
const [predication, promise] = await promiseRace(
|
|
2630
|
-
|
|
2628
|
+
if (promises.size >= maxConcurrency) {
|
|
2629
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2630
|
+
promises.delete(promise)
|
|
2631
2631
|
if (!predication) {
|
|
2632
2632
|
return false
|
|
2633
2633
|
}
|
|
@@ -2635,15 +2635,15 @@ const asyncIteratorEvery = async function (
|
|
|
2635
2635
|
|
|
2636
2636
|
const predication = predicate(iteration.value)
|
|
2637
2637
|
if (isPromise(predication)) {
|
|
2638
|
-
|
|
2638
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2639
2639
|
} else if (!predication) {
|
|
2640
2640
|
return false
|
|
2641
2641
|
}
|
|
2642
2642
|
iteration = await asyncIterator.next()
|
|
2643
2643
|
}
|
|
2644
|
-
while (
|
|
2645
|
-
const [predication, promise] = await promiseRace(
|
|
2646
|
-
|
|
2644
|
+
while (promises.size > 0) {
|
|
2645
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2646
|
+
promises.delete(promise)
|
|
2647
2647
|
if (!predication) {
|
|
2648
2648
|
return false
|
|
2649
2649
|
}
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.7.
|
|
2
|
+
* rubico v2.7.10
|
|
3
3
|
* https://github.com/a-synchronous/rubico
|
|
4
4
|
* (c) 2019-2026 Richard Tong
|
|
5
5
|
* rubico may be freely distributed under the MIT license.
|
|
@@ -2264,7 +2264,7 @@ const arrayForEach = function (array, callback) {
|
|
|
2264
2264
|
promises = []
|
|
2265
2265
|
let index = -1
|
|
2266
2266
|
while (++index < length) {
|
|
2267
|
-
const operation = callback(array[index])
|
|
2267
|
+
const operation = callback(array[index], index, array)
|
|
2268
2268
|
if (isPromise(operation)) {
|
|
2269
2269
|
promises.push(operation)
|
|
2270
2270
|
}
|
|
@@ -2275,7 +2275,7 @@ const arrayForEach = function (array, callback) {
|
|
|
2275
2275
|
const objectForEach = function (object, callback) {
|
|
2276
2276
|
const promises = []
|
|
2277
2277
|
for (const key in object) {
|
|
2278
|
-
const operation = callback(object[key])
|
|
2278
|
+
const operation = callback(object[key], key, object)
|
|
2279
2279
|
if (isPromise(operation)) {
|
|
2280
2280
|
promises.push(operation)
|
|
2281
2281
|
}
|
|
@@ -2314,7 +2314,7 @@ const arrayForEachSeries = function (array, callback) {
|
|
|
2314
2314
|
const length = array.length
|
|
2315
2315
|
let index = -1
|
|
2316
2316
|
while (++index < length) {
|
|
2317
|
-
const operation = callback(array[index])
|
|
2317
|
+
const operation = callback(array[index], index, array)
|
|
2318
2318
|
if (isPromise(operation)) {
|
|
2319
2319
|
return operation
|
|
2320
2320
|
.then(thunkify3(_arrayForEachSeriesAsync, array, callback, index))
|
|
@@ -2345,7 +2345,7 @@ const objectForEachSeries = function (object, callback) {
|
|
|
2345
2345
|
const doneKeys = {}
|
|
2346
2346
|
for (const key in object) {
|
|
2347
2347
|
doneKeys[key] = true
|
|
2348
|
-
const operation = callback(object[key])
|
|
2348
|
+
const operation = callback(object[key], key, object)
|
|
2349
2349
|
if (isPromise(operation)) {
|
|
2350
2350
|
return operation
|
|
2351
2351
|
.then(thunkify3(_objectForEachSeriesAsync, object, callback, doneKeys))
|
|
@@ -2461,21 +2461,21 @@ const SelfReferencingPromise = function (basePromise) {
|
|
|
2461
2461
|
}
|
|
2462
2462
|
|
|
2463
2463
|
const asyncArraySome = async function (
|
|
2464
|
-
array, predicate, index,
|
|
2464
|
+
array, predicate, index, promises,
|
|
2465
2465
|
) {
|
|
2466
2466
|
const length = array.length
|
|
2467
2467
|
|
|
2468
2468
|
while (++index < length) {
|
|
2469
2469
|
const predication = predicate(array[index])
|
|
2470
2470
|
if (isPromise(predication)) {
|
|
2471
|
-
|
|
2471
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2472
2472
|
} else if (predication) {
|
|
2473
2473
|
return true
|
|
2474
2474
|
}
|
|
2475
2475
|
}
|
|
2476
|
-
while (
|
|
2477
|
-
const [predication, promise] = await promiseRace(
|
|
2478
|
-
|
|
2476
|
+
while (promises.size > 0) {
|
|
2477
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2478
|
+
promises.delete(promise)
|
|
2479
2479
|
if (predication) {
|
|
2480
2480
|
return true
|
|
2481
2481
|
}
|
|
@@ -2500,7 +2500,7 @@ const arraySome = function (array, predicate) {
|
|
|
2500
2500
|
}
|
|
2501
2501
|
|
|
2502
2502
|
const asyncIteratorSome = async function (
|
|
2503
|
-
iterator, predicate,
|
|
2503
|
+
iterator, predicate, promises, maxConcurrency = 20,
|
|
2504
2504
|
) {
|
|
2505
2505
|
let iteration = iterator.next()
|
|
2506
2506
|
if (isPromise(iteration)) {
|
|
@@ -2508,16 +2508,16 @@ const asyncIteratorSome = async function (
|
|
|
2508
2508
|
}
|
|
2509
2509
|
|
|
2510
2510
|
while (!iteration.done) {
|
|
2511
|
-
if (
|
|
2512
|
-
const [predication, promise] = await promiseRace(
|
|
2513
|
-
|
|
2511
|
+
if (promises.size >= maxConcurrency) {
|
|
2512
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2513
|
+
promises.delete(promise)
|
|
2514
2514
|
if (predication) {
|
|
2515
2515
|
return true
|
|
2516
2516
|
}
|
|
2517
2517
|
}
|
|
2518
2518
|
const predication = predicate(iteration.value)
|
|
2519
2519
|
if (isPromise(predication)) {
|
|
2520
|
-
|
|
2520
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2521
2521
|
} else if (predication) {
|
|
2522
2522
|
return true
|
|
2523
2523
|
}
|
|
@@ -2526,9 +2526,9 @@ const asyncIteratorSome = async function (
|
|
|
2526
2526
|
iteration = await iteration
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
|
-
while (
|
|
2530
|
-
const [predication, promise] = await promiseRace(
|
|
2531
|
-
|
|
2529
|
+
while (promises.size > 0) {
|
|
2530
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2531
|
+
promises.delete(promise)
|
|
2532
2532
|
if (predication) {
|
|
2533
2533
|
return true
|
|
2534
2534
|
}
|
|
@@ -2627,13 +2627,13 @@ const iteratorEvery = function (iterator, predicate) {
|
|
|
2627
2627
|
}
|
|
2628
2628
|
|
|
2629
2629
|
const asyncIteratorEvery = async function (
|
|
2630
|
-
asyncIterator, predicate,
|
|
2630
|
+
asyncIterator, predicate, promises, maxConcurrency = 20,
|
|
2631
2631
|
) {
|
|
2632
2632
|
let iteration = await asyncIterator.next()
|
|
2633
2633
|
while (!iteration.done) {
|
|
2634
|
-
if (
|
|
2635
|
-
const [predication, promise] = await promiseRace(
|
|
2636
|
-
|
|
2634
|
+
if (promises.size >= maxConcurrency) {
|
|
2635
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2636
|
+
promises.delete(promise)
|
|
2637
2637
|
if (!predication) {
|
|
2638
2638
|
return false
|
|
2639
2639
|
}
|
|
@@ -2641,15 +2641,15 @@ const asyncIteratorEvery = async function (
|
|
|
2641
2641
|
|
|
2642
2642
|
const predication = predicate(iteration.value)
|
|
2643
2643
|
if (isPromise(predication)) {
|
|
2644
|
-
|
|
2644
|
+
promises.add(SelfReferencingPromise(predication))
|
|
2645
2645
|
} else if (!predication) {
|
|
2646
2646
|
return false
|
|
2647
2647
|
}
|
|
2648
2648
|
iteration = await asyncIterator.next()
|
|
2649
2649
|
}
|
|
2650
|
-
while (
|
|
2651
|
-
const [predication, promise] = await promiseRace(
|
|
2652
|
-
|
|
2650
|
+
while (promises.size > 0) {
|
|
2651
|
+
const [predication, promise] = await promiseRace(promises)
|
|
2652
|
+
promises.delete(promise)
|
|
2653
2653
|
if (!predication) {
|
|
2654
2654
|
return false
|
|
2655
2655
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rubico",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.10",
|
|
4
4
|
"description": "[a]synchronous functional programming",
|
|
5
5
|
"author": "Richard Tong",
|
|
6
6
|
"license": "MIT",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"test": "mocha test.js *.test.js */**.test.js",
|
|
88
|
+
"dist-test": "node dist-test.js && node dist-test.mjs",
|
|
88
89
|
"test-coverage": "nyc mocha test.js x/*.test.js monad/*.test.js",
|
|
89
90
|
"build": "npm run dts && ./build",
|
|
90
91
|
"bench": "./bench"
|