rubico 2.4.2 → 2.5.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/mapMapSeries.js +62 -0
- package/_internal/objectForEachSeries.js +6 -4
- package/_internal/objectMapSeries.js +61 -0
- package/_internal/setAdd.js +14 -0
- package/_internal/setMapSeries.js +61 -0
- package/_internal/stringMap.js +1 -1
- package/_internal/stringMapSeries.js +31 -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 +9 -7
- package/dist/forEach.es.min.js +2 -2
- package/dist/forEach.js +9 -7
- package/dist/forEach.min.js +2 -2
- package/dist/forEach.mjs +9 -7
- 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 +163 -9
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +163 -9
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +163 -9
- 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 +167 -19
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +167 -19
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +167 -19
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +167 -19
- package/dist/set.es.js +1 -1
- package/dist/set.es.min.js +1 -1
- package/dist/set.js +1 -1
- package/dist/set.min.js +1 -1
- package/dist/set.mjs +1 -1
- package/dist/some.es.js +1 -1
- package/dist/some.es.min.js +1 -1
- package/dist/some.js +1 -1
- package/dist/some.min.js +1 -1
- package/dist/some.mjs +1 -1
- package/dist/switchCase.es.js +1 -1
- package/dist/switchCase.es.min.js +1 -1
- package/dist/switchCase.js +1 -1
- package/dist/switchCase.min.js +1 -1
- package/dist/switchCase.mjs +1 -1
- package/dist/tap.es.js +1 -1
- package/dist/tap.es.min.js +1 -1
- package/dist/tap.js +1 -1
- package/dist/tap.min.js +1 -1
- package/dist/tap.mjs +1 -1
- package/dist/thunkify.es.js +1 -1
- package/dist/thunkify.es.min.js +1 -1
- package/dist/thunkify.js +1 -1
- package/dist/thunkify.min.js +1 -1
- package/dist/thunkify.mjs +1 -1
- package/dist/transform.es.js +1 -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 +163 -9
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +163 -9
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +163 -9
- package/dist/x/prepend.es.js +1 -1
- package/dist/x/prepend.es.min.js +1 -1
- package/dist/x/prepend.js +1 -1
- package/dist/x/prepend.min.js +1 -1
- package/dist/x/prepend.mjs +1 -1
- package/dist/x/size.es.js +1 -1
- package/dist/x/size.es.min.js +1 -1
- package/dist/x/size.js +1 -1
- package/dist/x/size.min.js +1 -1
- package/dist/x/size.mjs +1 -1
- package/dist/x/trace.es.js +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +1 -1
- package/dist/x/trace.mjs +1 -1
- package/dist/x/unionWith.es.js +1 -1
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +1 -1
- package/dist/x/unionWith.min.js +1 -1
- package/dist/x/unionWith.mjs +1 -1
- package/dist/x/uniq.es.js +1 -1
- package/dist/x/uniq.es.min.js +1 -1
- package/dist/x/uniq.js +1 -1
- package/dist/x/uniq.min.js +1 -1
- package/dist/x/uniq.mjs +1 -1
- package/dist/x/unless.es.js +1 -1
- package/dist/x/unless.es.min.js +1 -1
- package/dist/x/unless.js +1 -1
- package/dist/x/unless.min.js +1 -1
- package/dist/x/unless.mjs +1 -1
- package/dist/x/values.es.js +1 -1
- package/dist/x/values.es.min.js +1 -1
- package/dist/x/values.js +1 -1
- package/dist/x/values.min.js +1 -1
- package/dist/x/values.mjs +1 -1
- package/dist/x/when.es.js +1 -1
- package/dist/x/when.es.min.js +1 -1
- package/dist/x/when.js +1 -1
- package/dist/x/when.min.js +1 -1
- package/dist/x/when.mjs +1 -1
- package/es.js +167 -19
- package/forEach.js +2 -2
- package/index.js +167 -19
- package/map.js +62 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.
|
|
2
|
+
* rubico v2.5.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.
|
|
@@ -664,6 +664,135 @@ const arrayMapSeries = function (array, mapper) {
|
|
|
664
664
|
return result
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
const stringMapSeries = function (string, mapper) {
|
|
668
|
+
const result = arrayMapSeries(string, mapper)
|
|
669
|
+
return isPromise(result)
|
|
670
|
+
? result.then(curry3(callPropUnary, __, 'join', ''))
|
|
671
|
+
: result.join('')
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const thunkify4 = (func, arg0, arg1, arg2, arg3) => function thunk() {
|
|
675
|
+
return func(arg0, arg1, arg2, arg3)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// _objectMapSeriesAsync(
|
|
679
|
+
// object Object,
|
|
680
|
+
// f function,
|
|
681
|
+
// result Object,
|
|
682
|
+
// doneKeys Object
|
|
683
|
+
// ) -> Promise<object>
|
|
684
|
+
const _objectMapSeriesAsync = async function (object, f, result, doneKeys) {
|
|
685
|
+
for (const key in object) {
|
|
686
|
+
if (key in doneKeys) {
|
|
687
|
+
continue
|
|
688
|
+
}
|
|
689
|
+
let resultItem = f(object[key])
|
|
690
|
+
if (isPromise(resultItem)) {
|
|
691
|
+
resultItem = await resultItem
|
|
692
|
+
}
|
|
693
|
+
result[key] = resultItem
|
|
694
|
+
}
|
|
695
|
+
return result
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const objectMapSeries = function (object, f) {
|
|
699
|
+
const result = {}
|
|
700
|
+
const doneKeys = {}
|
|
701
|
+
for (const key in object) {
|
|
702
|
+
doneKeys[key] = true
|
|
703
|
+
const resultItem = f(object[key], key, object)
|
|
704
|
+
if (isPromise(resultItem)) {
|
|
705
|
+
return resultItem.then(funcConcat(
|
|
706
|
+
curry3(objectSet, result, key, __),
|
|
707
|
+
thunkify4(_objectMapSeriesAsync, object, f, result, doneKeys),
|
|
708
|
+
))
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return result
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const setAdd = function (set, value) {
|
|
715
|
+
set.add(value)
|
|
716
|
+
return set
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// _setMapSeriesAsync(
|
|
720
|
+
// iterator Iterator,
|
|
721
|
+
// f function,
|
|
722
|
+
// result Set,
|
|
723
|
+
// ) -> Promise<Set>
|
|
724
|
+
const _setMapSeriesAsync = async function (iterator, f, result) {
|
|
725
|
+
let iteration = iterator.next()
|
|
726
|
+
while (!iteration.done) {
|
|
727
|
+
let resultItem = f(iteration.value)
|
|
728
|
+
if (isPromise(resultItem)) {
|
|
729
|
+
resultItem = await resultItem
|
|
730
|
+
}
|
|
731
|
+
result.add(resultItem)
|
|
732
|
+
iteration = iterator.next()
|
|
733
|
+
}
|
|
734
|
+
return result
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const setMapSeries = function (set, f) {
|
|
738
|
+
const result = new Set()
|
|
739
|
+
const iterator = set[symbolIterator]()
|
|
740
|
+
let iteration = iterator.next()
|
|
741
|
+
while (!iteration.done) {
|
|
742
|
+
const resultItem = f(iteration.value)
|
|
743
|
+
if (isPromise(resultItem)) {
|
|
744
|
+
return resultItem.then(funcConcat(
|
|
745
|
+
curry2(setAdd, result, __),
|
|
746
|
+
thunkify3(_setMapSeriesAsync, iterator, f, result),
|
|
747
|
+
))
|
|
748
|
+
}
|
|
749
|
+
result.add(resultItem)
|
|
750
|
+
iteration = iterator.next()
|
|
751
|
+
}
|
|
752
|
+
return result
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const mapSet = function setting(source, key, value) {
|
|
756
|
+
return source.set(key, value)
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// _mapMapSeriesAsync(
|
|
760
|
+
// iterator Iterator,
|
|
761
|
+
// f function,
|
|
762
|
+
// result Map,
|
|
763
|
+
// ) -> Promise<Map>
|
|
764
|
+
const _mapMapSeriesAsync = async function (iterator, f, result) {
|
|
765
|
+
let iteration = iterator.next()
|
|
766
|
+
while (!iteration.done) {
|
|
767
|
+
let resultItem = f(iteration.value[1])
|
|
768
|
+
if (isPromise(resultItem)) {
|
|
769
|
+
resultItem = await resultItem
|
|
770
|
+
}
|
|
771
|
+
result.set(iteration.value[0], resultItem)
|
|
772
|
+
iteration = iterator.next()
|
|
773
|
+
}
|
|
774
|
+
return result
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const mapMapSeries = function (map, f) {
|
|
778
|
+
const result = new Map()
|
|
779
|
+
const iterator = map[symbolIterator]()
|
|
780
|
+
let iteration = iterator.next()
|
|
781
|
+
while (!iteration.done) {
|
|
782
|
+
const key = iteration.value[0]
|
|
783
|
+
const resultItem = f(iteration.value[1])
|
|
784
|
+
if (isPromise(resultItem)) {
|
|
785
|
+
return resultItem.then(funcConcat(
|
|
786
|
+
curry3(mapSet, result, key, __),
|
|
787
|
+
thunkify3(_mapMapSeriesAsync, iterator, f, result),
|
|
788
|
+
))
|
|
789
|
+
}
|
|
790
|
+
result.set(key, resultItem)
|
|
791
|
+
iteration = iterator.next()
|
|
792
|
+
}
|
|
793
|
+
return result
|
|
794
|
+
}
|
|
795
|
+
|
|
667
796
|
const tapSync = func => function tapping(...args) {
|
|
668
797
|
func(...args)
|
|
669
798
|
return args[0]
|
|
@@ -792,10 +921,6 @@ const objectMapEntries = function (object, mapper) {
|
|
|
792
921
|
: promiseAll(promises).then(always(result))
|
|
793
922
|
}
|
|
794
923
|
|
|
795
|
-
const mapSet = function setting(source, key, value) {
|
|
796
|
-
return source.set(key, value)
|
|
797
|
-
}
|
|
798
|
-
|
|
799
924
|
// (mapper function, result Map, promises Array<Promise>) => (key any, value any) => ()
|
|
800
925
|
const mapMapEntriesForEachCallback = (
|
|
801
926
|
mapper, result, promises,
|
|
@@ -884,11 +1009,36 @@ map.entries = function mapEntries(arg0, arg1) {
|
|
|
884
1009
|
: _mapEntries(arg0, arg1)
|
|
885
1010
|
}
|
|
886
1011
|
|
|
887
|
-
|
|
888
|
-
if (isArray(
|
|
889
|
-
return arrayMapSeries(
|
|
1012
|
+
const _mapSeries = function (collection, f) {
|
|
1013
|
+
if (isArray(collection)) {
|
|
1014
|
+
return arrayMapSeries(collection, f)
|
|
890
1015
|
}
|
|
891
|
-
|
|
1016
|
+
if (collection == null) {
|
|
1017
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
if (typeof collection == 'string' || collection.constructor == String) {
|
|
1021
|
+
return stringMapSeries(collection, f)
|
|
1022
|
+
}
|
|
1023
|
+
if (collection.constructor == Set) {
|
|
1024
|
+
return setMapSeries(collection, f)
|
|
1025
|
+
}
|
|
1026
|
+
if (collection.constructor == Map) {
|
|
1027
|
+
return mapMapSeries(collection, f)
|
|
1028
|
+
}
|
|
1029
|
+
if (collection.constructor == Object) {
|
|
1030
|
+
return objectMapSeries(collection, f)
|
|
1031
|
+
}
|
|
1032
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
map.series = function mapSeries(arg0, arg1) {
|
|
1036
|
+
if (typeof arg0 == 'function') {
|
|
1037
|
+
return curry2(_mapSeries, __, arg0)
|
|
1038
|
+
}
|
|
1039
|
+
return isPromise(arg0)
|
|
1040
|
+
? arg0.then(curry2(_mapSeries, __, arg1))
|
|
1041
|
+
: _mapSeries(arg0, arg1)
|
|
892
1042
|
}
|
|
893
1043
|
|
|
894
1044
|
map.pool = (concurrencyLimit, mapper) => function concurrentPoolMapping(value) {
|
|
@@ -1011,10 +1161,6 @@ const setFilter = function (value, predicate) {
|
|
|
1011
1161
|
: promiseAll(promises).then(always(result))
|
|
1012
1162
|
}
|
|
1013
1163
|
|
|
1014
|
-
const thunkify4 = (func, arg0, arg1, arg2, arg3) => function thunk() {
|
|
1015
|
-
return func(arg0, arg1, arg2, arg3)
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
1164
|
const mapFilter = function (map, predicate) {
|
|
1019
1165
|
const result = new Map(),
|
|
1020
1166
|
promises = []
|
|
@@ -1929,11 +2075,11 @@ const arrayForEachSeries = function (array, callback) {
|
|
|
1929
2075
|
// _objectForEachSeriesAsync(
|
|
1930
2076
|
// object Object,
|
|
1931
2077
|
// callback function,
|
|
1932
|
-
//
|
|
2078
|
+
// doneKeys Object,
|
|
1933
2079
|
// ) -> Promise<object>
|
|
1934
|
-
const _objectForEachSeriesAsync = async function (object, callback,
|
|
2080
|
+
const _objectForEachSeriesAsync = async function (object, callback, doneKeys) {
|
|
1935
2081
|
for (const key in object) {
|
|
1936
|
-
if (key
|
|
2082
|
+
if (key in doneKeys) {
|
|
1937
2083
|
continue
|
|
1938
2084
|
}
|
|
1939
2085
|
const operation = callback(object[key])
|
|
@@ -1945,11 +2091,13 @@ const _objectForEachSeriesAsync = async function (object, callback, firstKey) {
|
|
|
1945
2091
|
}
|
|
1946
2092
|
|
|
1947
2093
|
const objectForEachSeries = function (object, callback) {
|
|
2094
|
+
const doneKeys = {}
|
|
1948
2095
|
for (const key in object) {
|
|
2096
|
+
doneKeys[key] = true
|
|
1949
2097
|
const operation = callback(object[key])
|
|
1950
2098
|
if (isPromise(operation)) {
|
|
1951
2099
|
return operation
|
|
1952
|
-
.then(thunkify3(_objectForEachSeriesAsync, object, callback,
|
|
2100
|
+
.then(thunkify3(_objectForEachSeriesAsync, object, callback, doneKeys))
|
|
1953
2101
|
}
|
|
1954
2102
|
}
|
|
1955
2103
|
return object
|
|
@@ -2032,7 +2180,7 @@ const _forEachSeries = function (collection, callback) {
|
|
|
2032
2180
|
return arrayForEachSeries(collection, callback)
|
|
2033
2181
|
}
|
|
2034
2182
|
if (collection == null) {
|
|
2035
|
-
throw new
|
|
2183
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
2036
2184
|
}
|
|
2037
2185
|
if (typeof collection[symbolIterator] == 'function') {
|
|
2038
2186
|
return iteratorForEachSeries(collection[symbolIterator](), callback)
|
|
@@ -2043,7 +2191,7 @@ const _forEachSeries = function (collection, callback) {
|
|
|
2043
2191
|
if (collection.constructor == Object) {
|
|
2044
2192
|
return objectForEachSeries(collection, callback)
|
|
2045
2193
|
}
|
|
2046
|
-
throw new
|
|
2194
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
2047
2195
|
}
|
|
2048
2196
|
|
|
2049
2197
|
forEach.series = function forEachSeries(arg0, arg1) {
|
package/map.js
CHANGED
|
@@ -11,6 +11,10 @@ const setMap = require('./_internal/setMap')
|
|
|
11
11
|
const mapMap = require('./_internal/mapMap')
|
|
12
12
|
const objectMap = require('./_internal/objectMap')
|
|
13
13
|
const arrayMapSeries = require('./_internal/arrayMapSeries')
|
|
14
|
+
const stringMapSeries = require('./_internal/stringMapSeries')
|
|
15
|
+
const objectMapSeries = require('./_internal/objectMapSeries')
|
|
16
|
+
const setMapSeries = require('./_internal/setMapSeries')
|
|
17
|
+
const mapMapSeries = require('./_internal/mapMapSeries')
|
|
14
18
|
const arrayMapPool = require('./_internal/arrayMapPool')
|
|
15
19
|
const objectMapEntries = require('./_internal/objectMapEntries')
|
|
16
20
|
const mapMapEntries = require('./_internal/mapMapEntries')
|
|
@@ -105,10 +109,10 @@ const _map = function (value, mapper) {
|
|
|
105
109
|
* value any,
|
|
106
110
|
* indexOrKey number|string,
|
|
107
111
|
* collection Mappable
|
|
108
|
-
* )=>(
|
|
112
|
+
* )=>(resultItem Promise|any)
|
|
109
113
|
*
|
|
110
|
-
* map(
|
|
111
|
-
* map(
|
|
114
|
+
* map(collection Mappable, f Mapper) -> result Promise|Mappable
|
|
115
|
+
* map(f Mapper)(collection Mappable) -> result Promise|Mappable
|
|
112
116
|
* ```
|
|
113
117
|
*
|
|
114
118
|
* @description
|
|
@@ -309,11 +313,60 @@ map.entries = function mapEntries(arg0, arg1) {
|
|
|
309
313
|
: _mapEntries(arg0, arg1)
|
|
310
314
|
}
|
|
311
315
|
|
|
316
|
+
/**
|
|
317
|
+
* @name _mapSeries
|
|
318
|
+
*
|
|
319
|
+
* @synopsis
|
|
320
|
+
* ```coffeescript [specscript]
|
|
321
|
+
* type Mappable = Array|Object|Set|Map|Iterator|AsyncIterator
|
|
322
|
+
*
|
|
323
|
+
* type Mapper = (
|
|
324
|
+
* value any,
|
|
325
|
+
* indexOrKey number|string,
|
|
326
|
+
* collection Mappable
|
|
327
|
+
* )=>(mappedItem Promise|any)
|
|
328
|
+
*
|
|
329
|
+
* _mapSeries(collection Mappable, f Mapper) -> result Promise|Mappable
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
const _mapSeries = function (collection, f) {
|
|
333
|
+
if (isArray(collection)) {
|
|
334
|
+
return arrayMapSeries(collection, f)
|
|
335
|
+
}
|
|
336
|
+
if (collection == null) {
|
|
337
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (typeof collection == 'string' || collection.constructor == String) {
|
|
341
|
+
return stringMapSeries(collection, f)
|
|
342
|
+
}
|
|
343
|
+
if (collection.constructor == Set) {
|
|
344
|
+
return setMapSeries(collection, f)
|
|
345
|
+
}
|
|
346
|
+
if (collection.constructor == Map) {
|
|
347
|
+
return mapMapSeries(collection, f)
|
|
348
|
+
}
|
|
349
|
+
if (collection.constructor == Object) {
|
|
350
|
+
return objectMapSeries(collection, f)
|
|
351
|
+
}
|
|
352
|
+
throw new TypeError(`invalid collection ${collection}`)
|
|
353
|
+
}
|
|
354
|
+
|
|
312
355
|
/**
|
|
313
356
|
* @name map.series
|
|
314
357
|
*
|
|
315
358
|
* @synopsis
|
|
316
359
|
* ```coffeescript [specscript]
|
|
360
|
+
* type Mappable = Array|Object|Set|Map|Iterator|AsyncIterator
|
|
361
|
+
*
|
|
362
|
+
* type Mapper = (
|
|
363
|
+
* value any,
|
|
364
|
+
* indexOrKey number|string,
|
|
365
|
+
* collection Mappable
|
|
366
|
+
* )=>(mappedItem Promise|any)
|
|
367
|
+
*
|
|
368
|
+
* map.series( Mappable)
|
|
369
|
+
*
|
|
317
370
|
* map.series(
|
|
318
371
|
* mapperFunc (value any)=>Promise|any,
|
|
319
372
|
* )(array Array) -> Promise|Array
|
|
@@ -336,11 +389,13 @@ map.entries = function mapEntries(arg0, arg1) {
|
|
|
336
389
|
*
|
|
337
390
|
* @execution series
|
|
338
391
|
*/
|
|
339
|
-
map.series =
|
|
340
|
-
if (
|
|
341
|
-
return
|
|
392
|
+
map.series = function mapSeries(arg0, arg1) {
|
|
393
|
+
if (typeof arg0 == 'function') {
|
|
394
|
+
return curry2(_mapSeries, __, arg0)
|
|
342
395
|
}
|
|
343
|
-
|
|
396
|
+
return isPromise(arg0)
|
|
397
|
+
? arg0.then(curry2(_mapSeries, __, arg1))
|
|
398
|
+
: _mapSeries(arg0, arg1)
|
|
344
399
|
}
|
|
345
400
|
|
|
346
401
|
/**
|