rubico 2.8.5 → 2.10.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 +2 -1
- package/_internal/FlatMappingAsyncIterator.js +41 -30
- package/_internal/LinkedList.js +54 -0
- package/_internal/LinkedList.test.js +34 -0
- package/_internal/MappingAsyncIterator.js +65 -15
- package/_internal/SerialMappingAsyncIterator.js +79 -0
- package/_internal/curryArity.js +3 -3
- package/_internal/iteratorFind.js +0 -2
- package/_internal/iteratorForEachSeries.js +1 -1
- package/_internal/objectFlatten.js +4 -1
- package/all.js +33 -59
- package/and.js +1 -1
- package/assign.js +14 -16
- package/compose.js +12 -13
- package/curry.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 +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 +4 -4
- package/dist/curry.es.min.js +2 -2
- package/dist/curry.js +4 -4
- package/dist/curry.min.js +2 -2
- package/dist/curry.mjs +4 -4
- 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 +4 -4
- package/dist/filter.es.min.js +2 -2
- package/dist/filter.js +4 -4
- package/dist/filter.min.js +2 -2
- package/dist/filter.mjs +4 -4
- package/dist/flatMap.es.js +44 -28
- package/dist/flatMap.es.min.js +2 -2
- package/dist/flatMap.js +44 -28
- package/dist/flatMap.min.js +2 -2
- package/dist/flatMap.mjs +44 -28
- package/dist/forEach.es.js +6 -6
- package/dist/forEach.es.min.js +2 -2
- package/dist/forEach.js +6 -6
- package/dist/forEach.min.js +2 -2
- package/dist/forEach.mjs +6 -6
- package/dist/get.es.js +27 -3
- package/dist/get.es.min.js +2 -2
- package/dist/get.js +27 -3
- package/dist/get.min.js +2 -2
- package/dist/get.mjs +27 -3
- 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 +190 -42
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +190 -42
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +190 -42
- 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 +238 -83
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +238 -83
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +238 -83
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +238 -83
- 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 +4 -4
- package/dist/x/filterOut.es.min.js +2 -2
- package/dist/x/filterOut.js +4 -4
- package/dist/x/filterOut.min.js +2 -2
- package/dist/x/filterOut.mjs +4 -4
- package/dist/x/find.es.js +1 -3
- package/dist/x/find.es.min.js +1 -1
- package/dist/x/find.js +1 -3
- package/dist/x/find.min.js +1 -1
- package/dist/x/find.mjs +1 -3
- 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 +44 -28
- package/dist/x/flatten.es.min.js +2 -2
- package/dist/x/flatten.js +44 -28
- package/dist/x/flatten.min.js +2 -2
- package/dist/x/flatten.mjs +44 -28
- 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 +27 -23
- package/dist/x/maxBy.es.min.js +2 -2
- package/dist/x/maxBy.js +27 -23
- package/dist/x/maxBy.min.js +2 -2
- package/dist/x/maxBy.mjs +27 -23
- 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 +194 -44
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +194 -44
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +194 -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 +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +1 -1
- package/dist/x/trace.mjs +1 -1
- package/dist/x/unionWith.es.js +1 -1
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +1 -1
- package/dist/x/unionWith.min.js +1 -1
- package/dist/x/unionWith.mjs +1 -1
- package/dist/x/uniq.es.js +1 -1
- package/dist/x/uniq.es.min.js +1 -1
- package/dist/x/uniq.js +1 -1
- package/dist/x/uniq.min.js +1 -1
- package/dist/x/uniq.mjs +1 -1
- package/dist/x/unless.es.js +1 -1
- package/dist/x/unless.es.min.js +1 -1
- package/dist/x/unless.js +1 -1
- package/dist/x/unless.min.js +1 -1
- package/dist/x/unless.mjs +1 -1
- package/dist/x/values.es.js +1 -1
- package/dist/x/values.es.min.js +1 -1
- package/dist/x/values.js +1 -1
- package/dist/x/values.min.js +1 -1
- package/dist/x/values.mjs +1 -1
- package/dist/x/when.es.js +1 -1
- package/dist/x/when.es.min.js +1 -1
- package/dist/x/when.js +1 -1
- package/dist/x/when.min.js +1 -1
- package/dist/x/when.mjs +1 -1
- package/eq.js +2 -2
- package/es.js +238 -83
- package/every.js +2 -2
- package/filter.js +4 -4
- package/flatMap.js +61 -54
- package/forEach.js +33 -56
- package/get.js +49 -25
- package/gt.js +2 -2
- package/gte.js +2 -2
- package/index.js +238 -83
- package/lt.js +2 -2
- package/lte.js +2 -2
- package/map.js +115 -151
- package/monad/Mux.js +6 -4
- package/monad/PossiblePromise.js +6 -4
- package/monad/README.md +61 -40
- package/monad/Struct.js +6 -4
- package/not.js +1 -1
- package/omit.js +22 -19
- package/or.js +1 -1
- package/package.json +1 -1
- package/pick.js +14 -11
- package/pipe.js +18 -24
- package/reduce.js +1 -1
- package/set.js +17 -18
- package/some.js +2 -2
- package/switchCase.js +51 -43
- package/tap.js +17 -23
- package/transform.js +1 -1
- package/tryCatch.js +16 -24
- package/x/defaultsDeep.js +1 -1
- package/x/defaultsDeep.test.js +1 -1
- package/_internal/NextIteration.js +0 -12
- package/_internal/generatorFunctionFilter.js +0 -28
- package/_internal/iterationMap.js +0 -27
package/dist/rubico.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Rubico v2.
|
|
2
|
+
* Rubico v2.10.0
|
|
3
3
|
* https://rubico.land/
|
|
4
4
|
*
|
|
5
5
|
* © Richard Yufei Tong, King of Software
|
|
@@ -601,26 +601,167 @@ const MappingIterator = (iterator, mapper) => ({
|
|
|
601
601
|
},
|
|
602
602
|
})
|
|
603
603
|
|
|
604
|
-
const
|
|
604
|
+
const promiseRace = Promise.race.bind(Promise)
|
|
605
605
|
|
|
606
|
-
|
|
606
|
+
class LinkedList {
|
|
607
|
+
constructor() {
|
|
608
|
+
this.first = null
|
|
609
|
+
this.last = null
|
|
610
|
+
this.length = 0
|
|
611
|
+
}
|
|
607
612
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
613
|
+
// popFirst() -> firstValue any
|
|
614
|
+
popFirst() {
|
|
615
|
+
const first = this.first
|
|
616
|
+
|
|
617
|
+
if (first == null) {
|
|
618
|
+
return undefined
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (first.next) {
|
|
622
|
+
this.first = first.next
|
|
623
|
+
} else {
|
|
624
|
+
this.first = null
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
this.length -= 1
|
|
628
|
+
|
|
629
|
+
return first.value
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// append(value any) -> undefined
|
|
633
|
+
append(value) {
|
|
634
|
+
const node = { value }
|
|
635
|
+
if (this.first == null) {
|
|
636
|
+
this.first = node
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (this.last == null) {
|
|
640
|
+
this.last = node
|
|
641
|
+
} else {
|
|
642
|
+
this.last.next = node
|
|
643
|
+
this.last = node
|
|
616
644
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
? mapped.then(NextIteration)
|
|
620
|
-
: { value: mapped, done: false }
|
|
645
|
+
|
|
646
|
+
this.length += 1
|
|
621
647
|
}
|
|
648
|
+
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const symbolAsyncIterator = Symbol.asyncIterator
|
|
652
|
+
|
|
653
|
+
const arrayPush = function (array, value) {
|
|
654
|
+
array.push(value)
|
|
655
|
+
return array
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const sleep = time => new Promise(resolve => {
|
|
659
|
+
setTimeout(resolve, time)
|
|
622
660
|
})
|
|
623
661
|
|
|
662
|
+
const MappingAsyncIterator = (asyncIterator, mapper) => {
|
|
663
|
+
const buffer = new LinkedList()
|
|
664
|
+
|
|
665
|
+
let index = -1
|
|
666
|
+
let consumingAsyncIterator = false
|
|
667
|
+
let isAsyncIteratorDone = false
|
|
668
|
+
|
|
669
|
+
return {
|
|
670
|
+
[symbolAsyncIterator]() {
|
|
671
|
+
return this
|
|
672
|
+
},
|
|
673
|
+
|
|
674
|
+
// _consumeAsyncIterator() -> Promise<>
|
|
675
|
+
async _consumeAsyncIterator() {
|
|
676
|
+
for await (const item of asyncIterator) {
|
|
677
|
+
index += 1
|
|
678
|
+
const mappedItem = mapper(item)
|
|
679
|
+
buffer.append(mappedItem)
|
|
680
|
+
}
|
|
681
|
+
isAsyncIteratorDone = true
|
|
682
|
+
},
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
async next() {
|
|
686
|
+
if (!consumingAsyncIterator) {
|
|
687
|
+
this._consumeAsyncIterator()
|
|
688
|
+
consumingAsyncIterator = true
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
while (!isAsyncIteratorDone) {
|
|
692
|
+
if (buffer.length > 0) {
|
|
693
|
+
let value = buffer.popFirst()
|
|
694
|
+
if (isPromise(value)) {
|
|
695
|
+
value = await value
|
|
696
|
+
}
|
|
697
|
+
return { value, done: false }
|
|
698
|
+
}
|
|
699
|
+
await sleep(10)
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (buffer.length > 0) {
|
|
703
|
+
let value = buffer.popFirst()
|
|
704
|
+
if (isPromise(value)) {
|
|
705
|
+
value = await value
|
|
706
|
+
}
|
|
707
|
+
return { value, done: false }
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return { value: undefined, done: true }
|
|
711
|
+
},
|
|
712
|
+
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const SerialMappingAsyncIterator = (asyncIterator, mapper) => {
|
|
717
|
+
const buffer = new LinkedList()
|
|
718
|
+
|
|
719
|
+
let index = -1
|
|
720
|
+
let consumingAsyncIterator = false
|
|
721
|
+
let isAsyncIteratorDone = false
|
|
722
|
+
|
|
723
|
+
return {
|
|
724
|
+
[symbolAsyncIterator]() {
|
|
725
|
+
return this
|
|
726
|
+
},
|
|
727
|
+
|
|
728
|
+
// _consumeAsyncIterator() -> Promise<>
|
|
729
|
+
async _consumeAsyncIterator() {
|
|
730
|
+
for await (const item of asyncIterator) {
|
|
731
|
+
index += 1
|
|
732
|
+
let mappedItem = mapper(item)
|
|
733
|
+
if (isPromise(mappedItem)) {
|
|
734
|
+
mappedItem = await mappedItem
|
|
735
|
+
}
|
|
736
|
+
buffer.append(mappedItem)
|
|
737
|
+
}
|
|
738
|
+
isAsyncIteratorDone = true
|
|
739
|
+
},
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
async next() {
|
|
743
|
+
if (!consumingAsyncIterator) {
|
|
744
|
+
this._consumeAsyncIterator()
|
|
745
|
+
consumingAsyncIterator = true
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
while (!isAsyncIteratorDone) {
|
|
749
|
+
if (buffer.length > 0) {
|
|
750
|
+
return { value: buffer.popFirst(), done: false }
|
|
751
|
+
}
|
|
752
|
+
await sleep(10)
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (buffer.length > 0) {
|
|
756
|
+
return { value: buffer.popFirst(), done: false }
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return { value: undefined, done: true }
|
|
760
|
+
},
|
|
761
|
+
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
624
765
|
const isObject = value => {
|
|
625
766
|
if (value == null) {
|
|
626
767
|
return false
|
|
@@ -866,8 +1007,6 @@ const tapSync = func => function tapping(...args) {
|
|
|
866
1007
|
return args[0]
|
|
867
1008
|
}
|
|
868
1009
|
|
|
869
|
-
const promiseRace = Promise.race.bind(Promise)
|
|
870
|
-
|
|
871
1010
|
const arrayMapPoolAsync = async function (
|
|
872
1011
|
array, f, concurrencyLimit, result, index, promises,
|
|
873
1012
|
) {
|
|
@@ -1073,7 +1212,7 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1073
1212
|
curriedArgsIndex = -1,
|
|
1074
1213
|
numCurriedPlaceholders = 0
|
|
1075
1214
|
|
|
1076
|
-
while (
|
|
1215
|
+
while ((argsIndex += 1) < argsLength) {
|
|
1077
1216
|
const arg = args[argsIndex]
|
|
1078
1217
|
if (arg == __ && (curriedArgsIndex += 1) < curriedArgsLength) {
|
|
1079
1218
|
const curriedArg = curriedArgs[curriedArgsIndex]
|
|
@@ -1097,7 +1236,7 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
|
|
|
1097
1236
|
}
|
|
1098
1237
|
}
|
|
1099
1238
|
|
|
1100
|
-
while (
|
|
1239
|
+
while ((curriedArgsIndex += 1) < curriedArgsLength) {
|
|
1101
1240
|
const curriedArg = curriedArgs[curriedArgsIndex]
|
|
1102
1241
|
if (curriedArg == __) {
|
|
1103
1242
|
numCurriedPlaceholders += 1
|
|
@@ -1127,7 +1266,7 @@ const curryArity = function (arity, func, context, args) {
|
|
|
1127
1266
|
return _curryArity(arity, func, context, args)
|
|
1128
1267
|
}
|
|
1129
1268
|
let argsIndex = -1
|
|
1130
|
-
while (
|
|
1269
|
+
while ((argsIndex += 1) < argsLength) {
|
|
1131
1270
|
const arg = args[argsIndex]
|
|
1132
1271
|
if (arg == __) {
|
|
1133
1272
|
return _curryArity(arity, func, context, args)
|
|
@@ -1190,9 +1329,6 @@ const _map = function (value, f) {
|
|
|
1190
1329
|
if (typeof value.then == 'function') {
|
|
1191
1330
|
return value.then(f)
|
|
1192
1331
|
}
|
|
1193
|
-
if (typeof value.map == 'function') {
|
|
1194
|
-
return value.map(f)
|
|
1195
|
-
}
|
|
1196
1332
|
if (typeof value == 'string' || value.constructor == String) {
|
|
1197
1333
|
return stringMap(value, f)
|
|
1198
1334
|
}
|
|
@@ -1208,6 +1344,9 @@ const _map = function (value, f) {
|
|
|
1208
1344
|
if (typeof value[symbolAsyncIterator] == 'function') {
|
|
1209
1345
|
return MappingAsyncIterator(value[symbolAsyncIterator](), f)
|
|
1210
1346
|
}
|
|
1347
|
+
if (typeof value.map == 'function') {
|
|
1348
|
+
return value.map(f)
|
|
1349
|
+
}
|
|
1211
1350
|
if (value.constructor == Object) {
|
|
1212
1351
|
return objectMap(value, f)
|
|
1213
1352
|
}
|
|
@@ -1246,27 +1385,36 @@ map.entries = function mapEntries(arg0, arg1) {
|
|
|
1246
1385
|
: _mapEntries(arg0, arg1)
|
|
1247
1386
|
}
|
|
1248
1387
|
|
|
1249
|
-
const _mapSeries = function (
|
|
1250
|
-
if (isArray(
|
|
1251
|
-
return arrayMapSeries(
|
|
1388
|
+
const _mapSeries = function (functor, f) {
|
|
1389
|
+
if (isArray(functor)) {
|
|
1390
|
+
return arrayMapSeries(functor, f)
|
|
1252
1391
|
}
|
|
1253
|
-
if (
|
|
1254
|
-
throw new TypeError(`invalid
|
|
1392
|
+
if (functor == null) {
|
|
1393
|
+
throw new TypeError(`invalid functor ${functor}`)
|
|
1255
1394
|
}
|
|
1256
1395
|
|
|
1257
|
-
if (typeof
|
|
1258
|
-
return stringMapSeries(
|
|
1396
|
+
if (typeof functor == 'string' || functor.constructor == String) {
|
|
1397
|
+
return stringMapSeries(functor, f)
|
|
1259
1398
|
}
|
|
1260
|
-
if (
|
|
1261
|
-
return setMapSeries(
|
|
1399
|
+
if (functor.constructor == Set) {
|
|
1400
|
+
return setMapSeries(functor, f)
|
|
1262
1401
|
}
|
|
1263
|
-
if (
|
|
1264
|
-
return mapMapSeries(
|
|
1402
|
+
if (functor.constructor == Map) {
|
|
1403
|
+
return mapMapSeries(functor, f)
|
|
1265
1404
|
}
|
|
1266
|
-
if (
|
|
1267
|
-
return
|
|
1405
|
+
if (typeof functor[symbolIterator] == 'function') {
|
|
1406
|
+
return MappingIterator(functor[symbolIterator](), f)
|
|
1268
1407
|
}
|
|
1269
|
-
|
|
1408
|
+
if (typeof functor[symbolAsyncIterator] == 'function') {
|
|
1409
|
+
return SerialMappingAsyncIterator(functor[symbolAsyncIterator](), f)
|
|
1410
|
+
}
|
|
1411
|
+
if (typeof functor.map == 'function') {
|
|
1412
|
+
return functor.map(f)
|
|
1413
|
+
}
|
|
1414
|
+
if (functor.constructor == Object) {
|
|
1415
|
+
return objectMapSeries(functor, f)
|
|
1416
|
+
}
|
|
1417
|
+
throw new TypeError(`invalid functor ${functor}`)
|
|
1270
1418
|
}
|
|
1271
1419
|
|
|
1272
1420
|
map.series = function mapSeries(arg0, arg1) {
|
|
@@ -1483,15 +1631,15 @@ const _filter = function (value, predicate) {
|
|
|
1483
1631
|
if (value.constructor == Map) {
|
|
1484
1632
|
return mapFilter(value, predicate)
|
|
1485
1633
|
}
|
|
1486
|
-
if (typeof value.filter == 'function') {
|
|
1487
|
-
return value.filter(predicate)
|
|
1488
|
-
}
|
|
1489
1634
|
if (typeof value[symbolIterator] == 'function') {
|
|
1490
1635
|
return FilteringIterator(value[symbolIterator](), predicate)
|
|
1491
1636
|
}
|
|
1492
1637
|
if (typeof value[symbolAsyncIterator] == 'function') {
|
|
1493
1638
|
return FilteringAsyncIterator(value[symbolAsyncIterator](), predicate)
|
|
1494
1639
|
}
|
|
1640
|
+
if (typeof value.filter == 'function') {
|
|
1641
|
+
return value.filter(predicate)
|
|
1642
|
+
}
|
|
1495
1643
|
if (value.constructor == Object) {
|
|
1496
1644
|
return objectFilter(value, predicate)
|
|
1497
1645
|
}
|
|
@@ -1938,11 +2086,6 @@ const transform = function (...args) {
|
|
|
1938
2086
|
return _transform(args[0], args[1], args[2])
|
|
1939
2087
|
}
|
|
1940
2088
|
|
|
1941
|
-
const arrayPush = function (array, value) {
|
|
1942
|
-
array.push(value)
|
|
1943
|
-
return array
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
2089
|
const FlatMappingIterator = function (iterator, flatMapper) {
|
|
1947
2090
|
let buffer = [],
|
|
1948
2091
|
bufferIndex = 0
|
|
@@ -1977,13 +2120,12 @@ const FlatMappingIterator = function (iterator, flatMapper) {
|
|
|
1977
2120
|
}
|
|
1978
2121
|
}
|
|
1979
2122
|
|
|
1980
|
-
const sleep = time => new Promise(resolve => {
|
|
1981
|
-
setTimeout(resolve, time)
|
|
1982
|
-
})
|
|
1983
|
-
|
|
1984
2123
|
const FlatMappingAsyncIterator = function (asyncIterator, flatMapper) {
|
|
1985
|
-
const buffer = []
|
|
1986
|
-
|
|
2124
|
+
const buffer = []
|
|
2125
|
+
const promises = new Set()
|
|
2126
|
+
|
|
2127
|
+
let consumingAsyncIterator = false
|
|
2128
|
+
let isAsyncIteratorDone = false
|
|
1987
2129
|
|
|
1988
2130
|
return {
|
|
1989
2131
|
isAsyncIteratorDone: false,
|
|
@@ -1994,38 +2136,48 @@ const FlatMappingAsyncIterator = function (asyncIterator, flatMapper) {
|
|
|
1994
2136
|
return '[object FlatMappingAsyncIterator]'
|
|
1995
2137
|
},
|
|
1996
2138
|
|
|
1997
|
-
|
|
1998
|
-
async
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
2012
|
-
promises.add(promise)
|
|
2013
|
-
} else {
|
|
2014
|
-
const bufferLoading = genericReduce(monad, arrayPush, buffer)
|
|
2015
|
-
if (isPromise(bufferLoading)) {
|
|
2016
|
-
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
2017
|
-
promises.add(promise)
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2139
|
+
// _consumeAsyncIterator() -> Promise<>
|
|
2140
|
+
async _consumeAsyncIterator() {
|
|
2141
|
+
for await (const item of asyncIterator) {
|
|
2142
|
+
const monad = flatMapper(item)
|
|
2143
|
+
if (isPromise(monad)) {
|
|
2144
|
+
const bufferLoading =
|
|
2145
|
+
monad.then(curry3(genericReduce, __, arrayPush, buffer))
|
|
2146
|
+
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
2147
|
+
promises.add(promise)
|
|
2148
|
+
} else {
|
|
2149
|
+
const bufferLoading = genericReduce(monad, arrayPush, buffer)
|
|
2150
|
+
if (isPromise(bufferLoading)) {
|
|
2151
|
+
const promise = bufferLoading.then(() => promises.delete(promise))
|
|
2152
|
+
promises.add(promise)
|
|
2020
2153
|
}
|
|
2021
2154
|
}
|
|
2155
|
+
}
|
|
2156
|
+
isAsyncIteratorDone = true
|
|
2157
|
+
},
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
async next() {
|
|
2161
|
+
if (!consumingAsyncIterator) {
|
|
2162
|
+
this._consumeAsyncIterator()
|
|
2163
|
+
consumingAsyncIterator = true
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
while (!isAsyncIteratorDone || promises.size > 0) {
|
|
2022
2167
|
if (buffer.length > 0) {
|
|
2023
2168
|
return { value: buffer.shift(), done: false }
|
|
2024
2169
|
}
|
|
2025
2170
|
if (promises.size > 0) {
|
|
2026
|
-
await promiseRace(
|
|
2171
|
+
await promiseRace(promises)
|
|
2172
|
+
} else {
|
|
2173
|
+
await sleep(10)
|
|
2027
2174
|
}
|
|
2028
2175
|
}
|
|
2176
|
+
|
|
2177
|
+
if (buffer.length > 0) {
|
|
2178
|
+
return { value: buffer.shift(), done: false }
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2029
2181
|
return { value: undefined, done: true }
|
|
2030
2182
|
},
|
|
2031
2183
|
}
|
|
@@ -2121,9 +2273,12 @@ const objectFlatten = function (object) {
|
|
|
2121
2273
|
|
|
2122
2274
|
for (const key in object) {
|
|
2123
2275
|
const element = object[key]
|
|
2276
|
+
|
|
2124
2277
|
if (element == null) {
|
|
2125
2278
|
continue
|
|
2126
|
-
}
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
if (typeof element[symbolIterator] == 'function') {
|
|
2127
2282
|
for (const monadElement of element) {
|
|
2128
2283
|
objectAssign(result, monadElement)
|
|
2129
2284
|
}
|
|
@@ -2384,7 +2539,7 @@ const _iteratorForEachSeriesAsync = async function (iterator, callback) {
|
|
|
2384
2539
|
|
|
2385
2540
|
const iteratorForEachSeries = function (iterator, callback) {
|
|
2386
2541
|
let iteration = iterator.next()
|
|
2387
|
-
while (!
|
|
2542
|
+
while (!iteration.done) {
|
|
2388
2543
|
const operation = callback(iteration.value)
|
|
2389
2544
|
if (isPromise(operation)) {
|
|
2390
2545
|
return operation
|
|
@@ -2414,16 +2569,16 @@ const _forEach = function (collection, callback) {
|
|
|
2414
2569
|
if (collection == null) {
|
|
2415
2570
|
return collection
|
|
2416
2571
|
}
|
|
2417
|
-
if (typeof collection.forEach == 'function') {
|
|
2418
|
-
collection.forEach(callback)
|
|
2419
|
-
return collection
|
|
2420
|
-
}
|
|
2421
2572
|
if (typeof collection[symbolIterator] == 'function') {
|
|
2422
2573
|
return iteratorForEach(collection[symbolIterator](), callback)
|
|
2423
2574
|
}
|
|
2424
2575
|
if (typeof collection[symbolAsyncIterator] == 'function') {
|
|
2425
2576
|
return asyncIteratorForEach(collection[symbolAsyncIterator](), callback)
|
|
2426
2577
|
}
|
|
2578
|
+
if (typeof collection.forEach == 'function') {
|
|
2579
|
+
collection.forEach(callback)
|
|
2580
|
+
return collection
|
|
2581
|
+
}
|
|
2427
2582
|
if (collection.constructor == Object) {
|
|
2428
2583
|
return objectForEach(collection, callback)
|
|
2429
2584
|
}
|
|
@@ -3120,8 +3275,8 @@ const get = function (arg0, arg1, arg2) {
|
|
|
3120
3275
|
if (typeof arg0 == 'string' || typeof arg0 == 'number' || isArray(arg0)) {
|
|
3121
3276
|
return curry3(_get, __, arg0, arg1)
|
|
3122
3277
|
}
|
|
3123
|
-
if (isPromise(arg0)) {
|
|
3124
|
-
return arg0.then(
|
|
3278
|
+
if (isPromise(arg0) || isPromise(arg2)) {
|
|
3279
|
+
return promiseAll([arg0, arg1, arg2]).then(curry2(funcApply, _get, __))
|
|
3125
3280
|
}
|
|
3126
3281
|
return _get(arg0, arg1, arg2)
|
|
3127
3282
|
}
|