rubico 2.4.0 → 2.4.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/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 +7 -12
- package/dist/every.es.min.js +2 -2
- package/dist/every.js +7 -12
- package/dist/every.min.js +2 -2
- package/dist/every.mjs +7 -12
- package/dist/filter.es.js +5 -6
- package/dist/filter.es.min.js +2 -2
- package/dist/filter.js +5 -6
- package/dist/filter.min.js +2 -2
- package/dist/filter.mjs +5 -6
- package/dist/flatMap.es.js +7 -9
- package/dist/flatMap.es.min.js +2 -2
- package/dist/flatMap.js +7 -9
- package/dist/flatMap.min.js +2 -2
- package/dist/flatMap.mjs +7 -9
- package/dist/forEach.es.js +1 -1
- package/dist/forEach.es.min.js +1 -1
- package/dist/forEach.js +1 -1
- package/dist/forEach.min.js +1 -1
- package/dist/forEach.mjs +1 -1
- 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 +13 -21
- package/dist/map.es.min.js +2 -2
- package/dist/map.js +13 -21
- package/dist/map.min.js +2 -2
- package/dist/map.mjs +13 -21
- 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 +35 -56
- package/dist/rubico.es.min.js +2 -2
- package/dist/rubico.global.js +35 -56
- package/dist/rubico.global.min.js +2 -2
- package/dist/rubico.js +35 -56
- package/dist/rubico.min.js +2 -2
- package/dist/rubico.mjs +35 -56
- 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 +7 -12
- package/dist/some.es.min.js +2 -2
- package/dist/some.js +7 -12
- package/dist/some.min.js +2 -2
- package/dist/some.mjs +7 -12
- 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 +5 -6
- package/dist/x/filterOut.es.min.js +2 -2
- package/dist/x/filterOut.js +5 -6
- package/dist/x/filterOut.min.js +2 -2
- package/dist/x/filterOut.mjs +5 -6
- 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 +7 -9
- package/dist/x/flatten.es.min.js +2 -2
- package/dist/x/flatten.js +7 -9
- package/dist/x/flatten.min.js +2 -2
- package/dist/x/flatten.mjs +7 -9
- 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 +13 -21
- package/dist/x/pluck.es.min.js +2 -2
- package/dist/x/pluck.js +13 -21
- package/dist/x/pluck.min.js +2 -2
- package/dist/x/pluck.mjs +13 -21
- 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 +35 -56
- package/every.js +6 -11
- package/filter.js +4 -6
- package/flatMap.js +6 -8
- package/index.js +35 -56
- package/map.js +12 -21
- package/package.json +1 -1
- package/some.js +6 -12
package/dist/filter.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -311,12 +311,11 @@ const _filter = function (value, predicate) {
|
|
|
311
311
|
return value
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
const filter = function (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return curry2(_filter, __, predicate)
|
|
314
|
+
const filter = function (arg0, arg1) {
|
|
315
|
+
if (typeof arg0 == 'function') {
|
|
316
|
+
return curry2(_filter, __, arg0)
|
|
318
317
|
}
|
|
319
|
-
return _filter(
|
|
318
|
+
return _filter(arg0, arg1)
|
|
320
319
|
}
|
|
321
320
|
|
|
322
321
|
export default filter
|
package/dist/flatMap.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -809,15 +809,13 @@ const _flatMap = function (value, flatMapper) {
|
|
|
809
809
|
return flatMapper(value)
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
-
const flatMap = (
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
return curry2(_flatMap, __, flatMapper)
|
|
812
|
+
const flatMap = (arg0, arg1) => {
|
|
813
|
+
if (typeof arg0 == 'function') {
|
|
814
|
+
return curry2(_flatMap, __, arg0)
|
|
816
815
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
: _flatMap(args[0], flatMapper)
|
|
816
|
+
return isPromise(arg0)
|
|
817
|
+
? arg0.then(curry2(_flatMap, __, arg1))
|
|
818
|
+
: _flatMap(arg0, arg1)
|
|
821
819
|
}
|
|
822
820
|
|
|
823
821
|
export default flatMap
|
package/dist/flatMap.es.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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,isArray=Array.isArray,objectValues=Object.values,objectProto=Object.prototype,nativeObjectToString=objectProto.toString,objectToString=r=>nativeObjectToString.call(r),generatorFunctionTag="[object GeneratorFunction]",isGeneratorFunction=r=>objectToString(r)==generatorFunctionTag,asyncGeneratorFunctionTag="[object AsyncGeneratorFunction]",isAsyncGeneratorFunction=r=>objectToString(r)==asyncGeneratorFunctionTag,__=Symbol.for("placeholder"),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)},iteratorReduceAsync=async function(r,e,t){let n=r.next();if(n.done)return t;for(;!n.done;)t=e(t,n.value),isPromise(t)&&(t=await t),n=r.next();return t},iteratorReduce=function(r,e,t){let n=r.next();if(n.done)return t;for(void 0===t&&(t=n.value,n=r.next());!n.done;){if(t=e(t,n.value),isPromise(t))return t.then(curry3(iteratorReduceAsync,r,e,__));n=r.next()}return t},asyncIteratorReduce=async function(r,e,t){let n=await r.next();if(n.done)return t;for(void 0===t&&(t=n.value,n=await r.next());!n.done;)t=await e(t,n.value),n=await r.next();return t},symbolIterator=Symbol.iterator,symbolAsyncIterator=Symbol.asyncIterator,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)},curryArgs3ResolveArgs0=(r,e,t)=>function(...n){return r(n,e,t)},curryArgs3ResolveArgs1=(r,e,t)=>function(...n){return r(e,n,t)},curryArgs3ResolveArgs2=(r,e,t)=>function(...n){return r(e,t,n)},curryArgs3=function(r,e,t,n){return e==__?curryArgs3ResolveArgs0(r,t,n):t==__?curryArgs3ResolveArgs1(r,e,n):curryArgs3ResolveArgs2(r,e,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)},arrayReduceAsync=async function(r,e,t,n){const o=r.length;for(;++n<o;)t=e(t,r[n],n,r),isPromise(t)&&(t=await t);return t},arrayReduce=function(r,e,t){const n=r.length;let o=-1;for(void 0===t&&(t=r[++o]);++o<n;)if(t=e(t,r[o],o,r),isPromise(t))return t.then(curry4(arrayReduceAsync,r,e,__,o));return t},curry5ResolveArg0=(r,e,t,n,o)=>function(c){return r(c,e,t,n,o)},curry5ResolveArg1=(r,e,t,n,o)=>function(c){return r(e,c,t,n,o)},curry5ResolveArg2=(r,e,t,n,o)=>function(c){return r(e,t,c,n,o)},curry5ResolveArg3=(r,e,t,n,o)=>function(c){return r(e,t,n,c,o)},curry5ResolveArg4=(r,e,t,n,o)=>function(c){return r(e,t,n,o,c)},curry5=function(r,e,t,n,o,c){return e==__?curry5ResolveArg0(r,t,n,o,c):t==__?curry5ResolveArg1(r,e,n,o,c):n==__?curry5ResolveArg2(r,e,t,o,c):o==__?curry5ResolveArg3(r,e,t,n,c):curry5ResolveArg4(r,e,t,n,o)},objectKeys=Object.keys,objectReduceAsync=async function(r,e,t,n,o){const c=n.length;for(;++o<c;){const c=n[o];t=e(t,r[c],c,r),isPromise(t)&&(t=await t)}return t},objectReduce=function(r,e,t){const n=objectKeys(r),o=n.length;let c=-1;for(void 0===t&&(t=r[n[++c]]);++c<o;){const o=n[c];if(t=e(t,r[o],o,r),isPromise(t))return t.then((s=objectReduceAsync,u=e,a=__,l=n,y=c,(i=r)==__?curry5ResolveArg0(s,u,a,l,y):u==__?curry5ResolveArg1(s,i,a,l,y):a==__?curry5ResolveArg2(s,i,u,l,y):l==__?curry5ResolveArg3(s,i,u,a,y):curry5ResolveArg4(s,i,u,a,l)))}var s,i,u,a,l,y;return t},mapReduceAsync=async function(r,e,t,n){for(const[o,c]of n)t=e(t,c,o,r),isPromise(t)&&(t=await t);return t},mapReduce=function(r,e,t){const n=r.entries();if(void 0===t){const r=n.next();if(r.done)return t;t=r.value[1]}for(const[o,c]of n)if(t=e(t,c,o,r),isPromise(t))return t.then(curry4(mapReduceAsync,r,e,__,n));return t},reducerConcat=(r,e)=>function(t,n){const o=r(t,n);return isPromise(o)?o.then(curry2(e,__,n)):e(o,n)},genericReduce=function(r,e,t){return isArray(r)?arrayReduce(r,e,t):null==r?void 0===t?curry2(e,r,__):e(t,r):r.constructor==Map?mapReduce(r,e,t):"function"==typeof r[symbolIterator]?iteratorReduce(r[symbolIterator](),e,t):"function"==typeof r[symbolAsyncIterator]?asyncIteratorReduce(r[symbolAsyncIterator](),e,t):"function"==typeof r.reduce?r.reduce(e,t):"function"==typeof r.chain?r.chain(curry2(e,t,__)):"function"==typeof r.flatMap?r.flatMap(curry2(e,t,__)):r.constructor==Object?objectReduce(r,e,t):void 0===t?curry2(e,r,__):e(t,r)},arrayPush=function(r,e){return r.push(e),r},FlatMappingIterator=function(r,e){let t=[],n=0;return{[symbolIterator](){return this},next(){if(n<t.length){const r=t[n];return n+=1,{value:r,done:!1}}const o=r.next();if(o.done)return o;const c=genericReduce(e(o.value),arrayPush,[]);return c.length>1&&(t=c,n=1),{value:c[0],done:!1}}}},promiseRace=Promise.race.bind(Promise),sleep=r=>new Promise((e=>{setTimeout(e,r)})),FlatMappingAsyncIterator=function(r,e){const t=[],n=new Set;return{isAsyncIteratorDone:!1,[symbolAsyncIterator](){return this},toString:()=>"[object FlatMappingAsyncIterator]",async next(){for(;!this.isAsyncIteratorDone||t.length>0||n.size>0;){if(!this.isAsyncIteratorDone){const{value:o,done:c}=await r.next();if(c)this.isAsyncIteratorDone=c;else{const r=e(o);if(isPromise(r)){const e=r.then(curry3(genericReduce,__,arrayPush,t)).then((()=>n.delete(e)));n.add(e)}else{const e=genericReduce(r,arrayPush,t);if(isPromise(e)){const r=e.then((()=>n.delete(r)));n.add(r)}}}}if(t.length>0)return{value:t.shift(),done:!1};n.size>0&&await promiseRace([sleep(1e3),...n])}return{value:void 0,done:!0}}}},always=r=>function(){return r},getArg1=(r,e)=>e,identity=r=>r,promiseAll=Promise.all.bind(Promise),funcConcatSync=(r,e)=>function(...t){return e(r(...t))},asyncIteratorForEach=async function(r,e){const t=[];for await(const n of r){const r=e(n);isPromise(r)&&t.push(r)}return 0==t.length?r:promiseAll(t).then(always(r))},arrayFlatten=function(r){const e=r.length,t=[],n=[];let o=-1;for(;++o<e;){const e=r[o];if(isArray(e)){const r=e.length;let t=-1;for(;++t<r;)n.push(e[t])}else if(null==e)n.push(e);else if("function"==typeof e.then)t.push(e.then(curry2(arrayPush,n,__)));else if("function"==typeof e[symbolIterator])for(const r of e)n.push(r);else if("function"==typeof e[symbolAsyncIterator])t.push(asyncIteratorForEach(e[symbolAsyncIterator](),curry2(arrayPush,n,__)));else if("function"==typeof e.chain){const r=e.chain(identity);isPromise(r)?t.push(r.then(curry2(arrayPush,n,__))):n.push(r)}else if("function"==typeof e.flatMap){const r=e.flatMap(identity);isPromise(r)?t.push(r.then(curry2(arrayPush,n,__))):n.push(r)}else if("function"==typeof e.reduce){const r=e.reduce(funcConcatSync(getArg1,curry2(arrayPush,n,__)),null);isPromise(r)&&t.push(r)}else if(e.constructor==Object)for(const r in e)n.push(e[r]);else n.push(e)}return 0==t.length?n:promiseAll(t).then(always(n))},arrayMap=function(r,e){const t=r.length,n=Array(t);let o=-1,c=!1;for(;++o<t;){const t=e(r[o],o,r);isPromise(t)&&(c=!0),n[o]=t}return c?promiseAll(n):n},arrayFlatMap=function(r,e){const t=arrayMap(r,e);return isPromise(t)?t.then(arrayFlatten):arrayFlatten(t)},promiseObjectAllExecutor=r=>function(e){const t={};let n=0;for(const o in r){const c=r[o];isPromise(c)?(n+=1,c.then((r=>function(o){t[r]=o,n-=1,0==n&&e(t)})(o))):t[o]=c}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 c=e(r[o],o,r);isPromise(c)&&(n=!0),t[o]=c}return n?promiseObjectAll(t):t},objectAssign=Object.assign,objectFlatten=function(r){const e=[],t={},n=curry2(objectAssign,t,__),o=funcConcatSync(getArg1,n);for(const c in r){const s=r[c];if(null!=s)if("function"==typeof s[symbolIterator])for(const r of s)objectAssign(t,r);else if("function"==typeof s[symbolAsyncIterator])e.push(asyncIteratorForEach(s[symbolAsyncIterator](),n));else if("function"==typeof s.chain){const r=s.chain(identity);isPromise(r)?e.push(r.then(n)):objectAssign(t,r)}else if("function"==typeof s.flatMap){const r=s.flatMap(identity);isPromise(r)?e.push(r.then(n)):n(r)}else if("function"==typeof s.reduce){const r=s.reduce(o,null);isPromise(r)&&e.push(r)}else objectAssign(t,s)}return 0==e.length?t:promiseAll(e).then((()=>t))},objectFlatMap=function(r,e){const t=objectMap(r,e);return isPromise(t)?t.then(objectFlatten):objectFlatten(t)},callPropUnary=(r,e,t)=>r[e](t),setMap=function(r,e){const t=new Set,n=[];for(const o of r){const c=e(o,o,r);isPromise(c)?n.push(c.then(curry3(callPropUnary,t,"add",__))):t.add(c)}return 0==n.length?t:promiseAll(n).then(always(t))},setFlatten=function(r){r.size;const e=[],t=new Set,n=(r,e)=>t.add(e),o=curry3(callPropUnary,t,"add",__);for(const c of r)if(isArray(c)){const r=c.length;let e=-1;for(;++e<r;)t.add(c[e])}else if(null==c)t.add(c);else if("function"==typeof c[symbolIterator])for(const r of c)t.add(r);else if("function"==typeof c[symbolAsyncIterator])e.push(asyncIteratorForEach(c[symbolAsyncIterator](),o));else if("function"==typeof c.chain){const r=c.chain(identity);isPromise(r)?e.push(r.then(o)):t.add(r)}else if("function"==typeof c.flatMap){const r=c.flatMap(identity);isPromise(r)?e.push(r.then(o)):t.add(r)}else if("function"==typeof c.reduce){const r=c.reduce(n,null);isPromise(r)&&e.push(r)}else if(c.constructor==Object)for(const r in c)t.add(c[r]);else t.add(c);return 0==e.length?t:promiseAll(e).then((()=>t))},setFlatMap=function(r,e){const t=setMap(r,e);return isPromise(t)?t.then(setFlatten):setFlatten(t)},funcConcat=(r,e)=>function(...t){const n=r(...t);return isPromise(n)?n.then(e):e(n)},arrayJoin=(r,e)=>r.join(e),arrayFlattenToString=funcConcat(arrayFlatten,curry2(arrayJoin,__,"")),stringFlatMap=function(r,e){const t=arrayMap(r,e);return isPromise(t)?t.then(arrayFlattenToString):arrayFlattenToString(t)},_flatMap=function(r,e){if(isArray(r))return arrayFlatMap(r,e);if(null==r)return e(r);if("function"==typeof r.then)return r.then(e);if("function"==typeof r.next)return symbolIterator in r?FlatMappingIterator(r,e):FlatMappingAsyncIterator(r,e);if("function"==typeof r.chain)return r.chain(e);if("function"==typeof r.flatMap)return r.flatMap(e);const t=r.constructor;return t==Object?objectFlatMap(r,e):t==Set?setFlatMap(r,e):"string"==typeof r||t==String?stringFlatMap(r,e):e(r)},flatMap=(...r)=>{const e=r.pop();if(0==r.length)return curry2(_flatMap,__,e);const t=r[0];return isPromise(t)?t.then(curry2(_flatMap,__,e)):_flatMap(r[0],e)};export default flatMap;
|
|
7
|
+
const isPromise=e=>null!=e&&"function"==typeof e.then,isArray=Array.isArray,objectValues=Object.values,objectProto=Object.prototype,nativeObjectToString=objectProto.toString,objectToString=e=>nativeObjectToString.call(e),generatorFunctionTag="[object GeneratorFunction]",isGeneratorFunction=e=>objectToString(e)==generatorFunctionTag,asyncGeneratorFunctionTag="[object AsyncGeneratorFunction]",isAsyncGeneratorFunction=e=>objectToString(e)==asyncGeneratorFunctionTag,__=Symbol.for("placeholder"),curry3ResolveArg0=(e,r,t)=>function(n){return e(n,r,t)},curry3ResolveArg1=(e,r,t)=>function(n){return e(r,n,t)},curry3ResolveArg2=(e,r,t)=>function(n){return e(r,t,n)},curry3=function(e,r,t,n){return r==__?curry3ResolveArg0(e,t,n):t==__?curry3ResolveArg1(e,r,n):curry3ResolveArg2(e,r,t)},iteratorReduceAsync=async function(e,r,t){let n=e.next();if(n.done)return t;for(;!n.done;)t=r(t,n.value),isPromise(t)&&(t=await t),n=e.next();return t},iteratorReduce=function(e,r,t){let n=e.next();if(n.done)return t;for(void 0===t&&(t=n.value,n=e.next());!n.done;){if(t=r(t,n.value),isPromise(t))return t.then(curry3(iteratorReduceAsync,e,r,__));n=e.next()}return t},asyncIteratorReduce=async function(e,r,t){let n=await e.next();if(n.done)return t;for(void 0===t&&(t=n.value,n=await e.next());!n.done;)t=await r(t,n.value),n=await e.next();return t},symbolIterator=Symbol.iterator,symbolAsyncIterator=Symbol.asyncIterator,curry2ResolveArg0=(e,r)=>function(t){return e(t,r)},curry2ResolveArg1=(e,r)=>function(t){return e(r,t)},curry2=function(e,r,t){return r==__?curry2ResolveArg0(e,t):curry2ResolveArg1(e,r)},curryArgs3ResolveArgs0=(e,r,t)=>function(...n){return e(n,r,t)},curryArgs3ResolveArgs1=(e,r,t)=>function(...n){return e(r,n,t)},curryArgs3ResolveArgs2=(e,r,t)=>function(...n){return e(r,t,n)},curryArgs3=function(e,r,t,n){return r==__?curryArgs3ResolveArgs0(e,t,n):t==__?curryArgs3ResolveArgs1(e,r,n):curryArgs3ResolveArgs2(e,r,t)},curry4ResolveArg0=(e,r,t,n)=>function(o){return e(o,r,t,n)},curry4ResolveArg1=(e,r,t,n)=>function(o){return e(r,o,t,n)},curry4ResolveArg2=(e,r,t,n)=>function(o){return e(r,t,o,n)},curry4ResolveArg3=(e,r,t,n)=>function(o){return e(r,t,n,o)},curry4=function(e,r,t,n,o){return r==__?curry4ResolveArg0(e,t,n,o):t==__?curry4ResolveArg1(e,r,n,o):n==__?curry4ResolveArg2(e,r,t,o):curry4ResolveArg3(e,r,t,n)},arrayReduceAsync=async function(e,r,t,n){const o=e.length;for(;++n<o;)t=r(t,e[n],n,e),isPromise(t)&&(t=await t);return t},arrayReduce=function(e,r,t){const n=e.length;let o=-1;for(void 0===t&&(t=e[++o]);++o<n;)if(t=r(t,e[o],o,e),isPromise(t))return t.then(curry4(arrayReduceAsync,e,r,__,o));return t},curry5ResolveArg0=(e,r,t,n,o)=>function(c){return e(c,r,t,n,o)},curry5ResolveArg1=(e,r,t,n,o)=>function(c){return e(r,c,t,n,o)},curry5ResolveArg2=(e,r,t,n,o)=>function(c){return e(r,t,c,n,o)},curry5ResolveArg3=(e,r,t,n,o)=>function(c){return e(r,t,n,c,o)},curry5ResolveArg4=(e,r,t,n,o)=>function(c){return e(r,t,n,o,c)},curry5=function(e,r,t,n,o,c){return r==__?curry5ResolveArg0(e,t,n,o,c):t==__?curry5ResolveArg1(e,r,n,o,c):n==__?curry5ResolveArg2(e,r,t,o,c):o==__?curry5ResolveArg3(e,r,t,n,c):curry5ResolveArg4(e,r,t,n,o)},objectKeys=Object.keys,objectReduceAsync=async function(e,r,t,n,o){const c=n.length;for(;++o<c;){const c=n[o];t=r(t,e[c],c,e),isPromise(t)&&(t=await t)}return t},objectReduce=function(e,r,t){const n=objectKeys(e),o=n.length;let c=-1;for(void 0===t&&(t=e[n[++c]]);++c<o;){const o=n[c];if(t=r(t,e[o],o,e),isPromise(t))return t.then((s=objectReduceAsync,u=r,a=__,l=n,y=c,(i=e)==__?curry5ResolveArg0(s,u,a,l,y):u==__?curry5ResolveArg1(s,i,a,l,y):a==__?curry5ResolveArg2(s,i,u,l,y):l==__?curry5ResolveArg3(s,i,u,a,y):curry5ResolveArg4(s,i,u,a,l)))}var s,i,u,a,l,y;return t},mapReduceAsync=async function(e,r,t,n){for(const[o,c]of n)t=r(t,c,o,e),isPromise(t)&&(t=await t);return t},mapReduce=function(e,r,t){const n=e.entries();if(void 0===t){const e=n.next();if(e.done)return t;t=e.value[1]}for(const[o,c]of n)if(t=r(t,c,o,e),isPromise(t))return t.then(curry4(mapReduceAsync,e,r,__,n));return t},reducerConcat=(e,r)=>function(t,n){const o=e(t,n);return isPromise(o)?o.then(curry2(r,__,n)):r(o,n)},genericReduce=function(e,r,t){return isArray(e)?arrayReduce(e,r,t):null==e?void 0===t?curry2(r,e,__):r(t,e):e.constructor==Map?mapReduce(e,r,t):"function"==typeof e[symbolIterator]?iteratorReduce(e[symbolIterator](),r,t):"function"==typeof e[symbolAsyncIterator]?asyncIteratorReduce(e[symbolAsyncIterator](),r,t):"function"==typeof e.reduce?e.reduce(r,t):"function"==typeof e.chain?e.chain(curry2(r,t,__)):"function"==typeof e.flatMap?e.flatMap(curry2(r,t,__)):e.constructor==Object?objectReduce(e,r,t):void 0===t?curry2(r,e,__):r(t,e)},arrayPush=function(e,r){return e.push(r),e},FlatMappingIterator=function(e,r){let t=[],n=0;return{[symbolIterator](){return this},next(){if(n<t.length){const e=t[n];return n+=1,{value:e,done:!1}}const o=e.next();if(o.done)return o;const c=genericReduce(r(o.value),arrayPush,[]);return c.length>1&&(t=c,n=1),{value:c[0],done:!1}}}},promiseRace=Promise.race.bind(Promise),sleep=e=>new Promise((r=>{setTimeout(r,e)})),FlatMappingAsyncIterator=function(e,r){const t=[],n=new Set;return{isAsyncIteratorDone:!1,[symbolAsyncIterator](){return this},toString:()=>"[object FlatMappingAsyncIterator]",async next(){for(;!this.isAsyncIteratorDone||t.length>0||n.size>0;){if(!this.isAsyncIteratorDone){const{value:o,done:c}=await e.next();if(c)this.isAsyncIteratorDone=c;else{const e=r(o);if(isPromise(e)){const r=e.then(curry3(genericReduce,__,arrayPush,t)).then((()=>n.delete(r)));n.add(r)}else{const r=genericReduce(e,arrayPush,t);if(isPromise(r)){const e=r.then((()=>n.delete(e)));n.add(e)}}}}if(t.length>0)return{value:t.shift(),done:!1};n.size>0&&await promiseRace([sleep(1e3),...n])}return{value:void 0,done:!0}}}},always=e=>function(){return e},getArg1=(e,r)=>r,identity=e=>e,promiseAll=Promise.all.bind(Promise),funcConcatSync=(e,r)=>function(...t){return r(e(...t))},asyncIteratorForEach=async function(e,r){const t=[];for await(const n of e){const e=r(n);isPromise(e)&&t.push(e)}return 0==t.length?e:promiseAll(t).then(always(e))},arrayFlatten=function(e){const r=e.length,t=[],n=[];let o=-1;for(;++o<r;){const r=e[o];if(isArray(r)){const e=r.length;let t=-1;for(;++t<e;)n.push(r[t])}else if(null==r)n.push(r);else if("function"==typeof r.then)t.push(r.then(curry2(arrayPush,n,__)));else if("function"==typeof r[symbolIterator])for(const e of r)n.push(e);else if("function"==typeof r[symbolAsyncIterator])t.push(asyncIteratorForEach(r[symbolAsyncIterator](),curry2(arrayPush,n,__)));else if("function"==typeof r.chain){const e=r.chain(identity);isPromise(e)?t.push(e.then(curry2(arrayPush,n,__))):n.push(e)}else if("function"==typeof r.flatMap){const e=r.flatMap(identity);isPromise(e)?t.push(e.then(curry2(arrayPush,n,__))):n.push(e)}else if("function"==typeof r.reduce){const e=r.reduce(funcConcatSync(getArg1,curry2(arrayPush,n,__)),null);isPromise(e)&&t.push(e)}else if(r.constructor==Object)for(const e in r)n.push(r[e]);else n.push(r)}return 0==t.length?n:promiseAll(t).then(always(n))},arrayMap=function(e,r){const t=e.length,n=Array(t);let o=-1,c=!1;for(;++o<t;){const t=r(e[o],o,e);isPromise(t)&&(c=!0),n[o]=t}return c?promiseAll(n):n},arrayFlatMap=function(e,r){const t=arrayMap(e,r);return isPromise(t)?t.then(arrayFlatten):arrayFlatten(t)},promiseObjectAllExecutor=e=>function(r){const t={};let n=0;for(const o in e){const c=e[o];isPromise(c)?(n+=1,c.then((e=>function(o){t[e]=o,n-=1,0==n&&r(t)})(o))):t[o]=c}0==n&&r(t)},promiseObjectAll=e=>new Promise(promiseObjectAllExecutor(e)),objectMap=function(e,r){const t={};let n=!1;for(const o in e){const c=r(e[o],o,e);isPromise(c)&&(n=!0),t[o]=c}return n?promiseObjectAll(t):t},objectAssign=Object.assign,objectFlatten=function(e){const r=[],t={},n=curry2(objectAssign,t,__),o=funcConcatSync(getArg1,n);for(const c in e){const s=e[c];if(null!=s)if("function"==typeof s[symbolIterator])for(const e of s)objectAssign(t,e);else if("function"==typeof s[symbolAsyncIterator])r.push(asyncIteratorForEach(s[symbolAsyncIterator](),n));else if("function"==typeof s.chain){const e=s.chain(identity);isPromise(e)?r.push(e.then(n)):objectAssign(t,e)}else if("function"==typeof s.flatMap){const e=s.flatMap(identity);isPromise(e)?r.push(e.then(n)):n(e)}else if("function"==typeof s.reduce){const e=s.reduce(o,null);isPromise(e)&&r.push(e)}else objectAssign(t,s)}return 0==r.length?t:promiseAll(r).then((()=>t))},objectFlatMap=function(e,r){const t=objectMap(e,r);return isPromise(t)?t.then(objectFlatten):objectFlatten(t)},callPropUnary=(e,r,t)=>e[r](t),setMap=function(e,r){const t=new Set,n=[];for(const o of e){const c=r(o,o,e);isPromise(c)?n.push(c.then(curry3(callPropUnary,t,"add",__))):t.add(c)}return 0==n.length?t:promiseAll(n).then(always(t))},setFlatten=function(e){e.size;const r=[],t=new Set,n=(e,r)=>t.add(r),o=curry3(callPropUnary,t,"add",__);for(const c of e)if(isArray(c)){const e=c.length;let r=-1;for(;++r<e;)t.add(c[r])}else if(null==c)t.add(c);else if("function"==typeof c[symbolIterator])for(const e of c)t.add(e);else if("function"==typeof c[symbolAsyncIterator])r.push(asyncIteratorForEach(c[symbolAsyncIterator](),o));else if("function"==typeof c.chain){const e=c.chain(identity);isPromise(e)?r.push(e.then(o)):t.add(e)}else if("function"==typeof c.flatMap){const e=c.flatMap(identity);isPromise(e)?r.push(e.then(o)):t.add(e)}else if("function"==typeof c.reduce){const e=c.reduce(n,null);isPromise(e)&&r.push(e)}else if(c.constructor==Object)for(const e in c)t.add(c[e]);else t.add(c);return 0==r.length?t:promiseAll(r).then((()=>t))},setFlatMap=function(e,r){const t=setMap(e,r);return isPromise(t)?t.then(setFlatten):setFlatten(t)},funcConcat=(e,r)=>function(...t){const n=e(...t);return isPromise(n)?n.then(r):r(n)},arrayJoin=(e,r)=>e.join(r),arrayFlattenToString=funcConcat(arrayFlatten,curry2(arrayJoin,__,"")),stringFlatMap=function(e,r){const t=arrayMap(e,r);return isPromise(t)?t.then(arrayFlattenToString):arrayFlattenToString(t)},_flatMap=function(e,r){if(isArray(e))return arrayFlatMap(e,r);if(null==e)return r(e);if("function"==typeof e.then)return e.then(r);if("function"==typeof e.next)return symbolIterator in e?FlatMappingIterator(e,r):FlatMappingAsyncIterator(e,r);if("function"==typeof e.chain)return e.chain(r);if("function"==typeof e.flatMap)return e.flatMap(r);const t=e.constructor;return t==Object?objectFlatMap(e,r):t==Set?setFlatMap(e,r):"string"==typeof e||t==String?stringFlatMap(e,r):r(e)},flatMap=(e,r)=>"function"==typeof e?curry2(_flatMap,__,e):isPromise(e)?e.then(curry2(_flatMap,__,r)):_flatMap(e,r);export default flatMap;
|
package/dist/flatMap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -815,15 +815,13 @@ const _flatMap = function (value, flatMapper) {
|
|
|
815
815
|
return flatMapper(value)
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
const flatMap = (
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
return curry2(_flatMap, __, flatMapper)
|
|
818
|
+
const flatMap = (arg0, arg1) => {
|
|
819
|
+
if (typeof arg0 == 'function') {
|
|
820
|
+
return curry2(_flatMap, __, arg0)
|
|
822
821
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
: _flatMap(args[0], flatMapper)
|
|
822
|
+
return isPromise(arg0)
|
|
823
|
+
? arg0.then(curry2(_flatMap, __, arg1))
|
|
824
|
+
: _flatMap(arg0, arg1)
|
|
827
825
|
}
|
|
828
826
|
|
|
829
827
|
return flatMap
|
package/dist/flatMap.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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
7
|
|
|
8
|
-
!function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define((()=>t)):n.flatMap=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=n=>null!=n&&"function"==typeof n.then,t=Array.isArray,e=(Object.values,Object.prototype.toString,Symbol.for("placeholder")),o=function(n,t,o,r){return t==e?((n,t,e)=>function(o){return n(o,t,e)})(n,o,r):o==e?((n,t,e)=>function(o){return n(t,o,e)})(n,t,r):((n,t,e)=>function(o){return n(t,e,o)})(n,t,o)},r=async function(t,e,o){let r=t.next();if(r.done)return o;for(;!r.done;)o=e(o,r.value),n(o)&&(o=await o),r=t.next();return o},u=Symbol.iterator,f=Symbol.asyncIterator,c=function(n,t,o){return t==e?((n,t)=>function(e){return n(e,t)})(n,o):((n,t)=>function(e){return n(t,e)})(n,t)},i=function(n,t,o,r,u){return t==e?((n,t,e,o)=>function(r){return n(r,t,e,o)})(n,o,r,u):o==e?((n,t,e,o)=>function(r){return n(t,r,e,o)})(n,t,r,u):r==e?((n,t,e,o)=>function(r){return n(t,e,r,o)})(n,t,o,u):((n,t,e,o)=>function(r){return n(t,e,o,r)})(n,t,o,r)},s=async function(t,e,o,r){const u=t.length;for(;++r<u;)o=e(o,t[r],r,t),n(o)&&(o=await o);return o},l=Object.keys,a=async function(t,e,o,r,u){const f=r.length;for(;++u<f;){const f=r[u];o=e(o,t[f],f,t),n(o)&&(o=await o)}return o},h=async function(t,e,o,r){for(const[u,f]of r)o=e(o,f,u,t),n(o)&&(o=await o);return o},p=function(p,d,y){return t(p)?function(t,o,r){const u=t.length;let f=-1;for(void 0===r&&(r=t[++f]);++f<u;)if(r=o(r,t[f],f,t),n(r))return r.then(i(s,t,o,e,f));return r}(p,d,y):null==p?void 0===y?c(d,p,e):d(y,p):p.constructor==Map?function(t,o,r){const u=t.entries();if(void 0===r){const n=u.next();if(n.done)return r;r=n.value[1]}for(const[f,c]of u)if(r=o(r,c,f,t),n(r))return r.then(i(h,t,o,e,u));return r}(p,d,y):"function"==typeof p[u]?function(t,u,f){let c=t.next();if(c.done)return f;for(void 0===f&&(f=c.value,c=t.next());!c.done;){if(f=u(f,c.value),n(f))return f.then(o(r,t,u,e));c=t.next()}return f}(p[u](),d,y):"function"==typeof p[f]?async function(n,t,e){let o=await n.next();if(o.done)return e;for(void 0===e&&(e=o.value,o=await n.next());!o.done;)e=await t(e,o.value),o=await n.next();return e}(p[f](),d,y):"function"==typeof p.reduce?p.reduce(d,y):"function"==typeof p.chain?p.chain(c(d,y,e)):"function"==typeof p.flatMap?p.flatMap(c(d,y,e)):p.constructor==Object?function(t,o,r){const u=l(t),f=u.length;let c=-1;for(void 0===r&&(r=t[u[++c]]);++c<f;){const f=u[c];if(r=o(r,t[f],f,t),n(r))return r.then((i=a,h=o,p=e,d=u,y=c,(s=t)==e?((n,t,e,o,r)=>function(u){return n(u,t,e,o,r)})(i,h,p,d,y):h==e?((n,t,e,o,r)=>function(u){return n(t,u,e,o,r)})(i,s,p,d,y):p==e?((n,t,e,o,r)=>function(u){return n(t,e,u,o,r)})(i,s,h,d,y):d==e?((n,t,e,o,r)=>function(u){return n(t,e,o,u,r)})(i,s,h,p,y):((n,t,e,o,r)=>function(u){return n(t,e,o,r,u)})(i,s,h,p,d)))}var i,s,h,p,d,y;return r}(p,d,y):void 0===y?c(d,p,e):d(y,p)},d=function(n,t){return n.push(t),n},y=Promise.race.bind(Promise),g=n=>new Promise((t=>{setTimeout(t,n)})),v=n=>function(){return n},b=(n,t)=>t,w=n=>n,x=Promise.all.bind(Promise),M=(n,t)=>function(...e){return t(n(...e))},j=async function(t,e){const o=[];for await(const r of t){const t=e(r);n(t)&&o.push(t)}return 0==o.length?t:x(o).then(v(t))},m=function(o){const r=o.length,i=[],s=[];let l=-1;for(;++l<r;){const r=o[l];if(t(r)){const n=r.length;let t=-1;for(;++t<n;)s.push(r[t])}else if(null==r)s.push(r);else if("function"==typeof r.then)i.push(r.then(c(d,s,e)));else if("function"==typeof r[u])for(const n of r)s.push(n);else if("function"==typeof r[f])i.push(j(r[f](),c(d,s,e)));else if("function"==typeof r.chain){const t=r.chain(w);n(t)?i.push(t.then(c(d,s,e))):s.push(t)}else if("function"==typeof r.flatMap){const t=r.flatMap(w);n(t)?i.push(t.then(c(d,s,e))):s.push(t)}else if("function"==typeof r.reduce){const t=r.reduce(M(b,c(d,s,e)),null);n(t)&&i.push(t)}else if(r.constructor==Object)for(const n in r)s.push(r[n]);else s.push(r)}return 0==i.length?s:x(i).then(v(s))},S=function(t,e){const o=t.length,r=Array(o);let u=-1,f=!1;for(;++u<o;){const o=e(t[u],u,t);n(o)&&(f=!0),r[u]=o}return f?x(r):r},A=t=>new Promise((t=>function(e){const o={};let r=0;for(const u in t){const f=t[u];n(f)?(r+=1,f.then((n=>function(t){o[n]=t,r-=1,0==r&&e(o)})(u))):o[u]=f}0==r&&e(o)})(t)),O=Object.assign,I=function(t){const o=[],r={},i=c(O,r,e),s=M(b,i);for(const e in t){const c=t[e];if(null!=c)if("function"==typeof c[u])for(const n of c)O(r,n);else if("function"==typeof c[f])o.push(j(c[f](),i));else if("function"==typeof c.chain){const t=c.chain(w);n(t)?o.push(t.then(i)):O(r,t)}else if("function"==typeof c.flatMap){const t=c.flatMap(w);n(t)?o.push(t.then(i)):i(t)}else if("function"==typeof c.reduce){const t=c.reduce(s,null);n(t)&&o.push(t)}else O(r,c)}return 0==o.length?r:x(o).then((()=>r))},P=function(t,e){const o=function(t,e){const o={};let r=!1;for(const u in t){const f=e(t[u],u,t);n(f)&&(r=!0),o[u]=f}return r?A(o):o}(t,e);return n(o)?o.then(I):I(o)},D=(n,t,e)=>n[t](e),z=function(r){r.size;const c=[],i=new Set,s=(n,t)=>i.add(t),l=o(D,i,"add",e);for(const e of r)if(t(e)){const n=e.length;let t=-1;for(;++t<n;)i.add(e[t])}else if(null==e)i.add(e);else if("function"==typeof e[u])for(const n of e)i.add(n);else if("function"==typeof e[f])c.push(j(e[f](),l));else if("function"==typeof e.chain){const t=e.chain(w);n(t)?c.push(t.then(l)):i.add(t)}else if("function"==typeof e.flatMap){const t=e.flatMap(w);n(t)?c.push(t.then(l)):i.add(t)}else if("function"==typeof e.reduce){const t=e.reduce(s,null);n(t)&&c.push(t)}else if(e.constructor==Object)for(const n in e)i.add(e[n]);else i.add(e);return 0==c.length?i:x(c).then((()=>i))},T=function(t,r){const u=function(t,r){const u=new Set,f=[];for(const c of t){const i=r(c,c,t);n(i)?f.push(i.then(o(D,u,"add",e))):u.add(i)}return 0==f.length?u:x(f).then(v(u))}(t,r);return n(u)?u.then(z):z(u)},k=(F=m,q=c(((n,t)=>n.join(t)),e,""),function(...t){const e=F(...t);return n(e)?e.then(q):q(e)});var F,q;const B=function(r,c){if(t(r))return function(t,e){const o=S(t,e);return n(o)?o.then(m):m(o)}(r,c);if(null==r)return c(r);if("function"==typeof r.then)return r.then(c);if("function"==typeof r.next)return u in r?function(n,t){let e=[],o=0;return{[u](){return this},next(){if(o<e.length){const n=e[o];return o+=1,{value:n,done:!1}}const r=n.next();if(r.done)return r;const u=p(t(r.value),d,[]);return u.length>1&&(e=u,o=1),{value:u[0],done:!1}}}}(r,c):function(t,r){const u=[],c=new Set;return{isAsyncIteratorDone:!1,[f](){return this},toString:()=>"[object FlatMappingAsyncIterator]",async next(){for(;!this.isAsyncIteratorDone||u.length>0||c.size>0;){if(!this.isAsyncIteratorDone){const{value:f,done:i}=await t.next();if(i)this.isAsyncIteratorDone=i;else{const t=r(f);if(n(t)){const n=t.then(o(p,e,d,u)).then((()=>c.delete(n)));c.add(n)}else{const e=p(t,d,u);if(n(e)){const n=e.then((()=>c.delete(n)));c.add(n)}}}}if(u.length>0)return{value:u.shift(),done:!1};c.size>0&&await y([g(1e3),...c])}return{value:void 0,done:!0}}}}(r,c);if("function"==typeof r.chain)return r.chain(c);if("function"==typeof r.flatMap)return r.flatMap(c);const i=r.constructor;return i==Object?P(r,c):i==Set?T(r,c):"string"==typeof r||i==String?function(t,e){const o=S(t,e);return n(o)?o.then(k):k(o)}(r,c):c(r)};return(
|
|
8
|
+
!function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define((()=>t)):n.flatMap=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=n=>null!=n&&"function"==typeof n.then,t=Array.isArray,e=(Object.values,Object.prototype.toString,Symbol.for("placeholder")),o=function(n,t,o,r){return t==e?((n,t,e)=>function(o){return n(o,t,e)})(n,o,r):o==e?((n,t,e)=>function(o){return n(t,o,e)})(n,t,r):((n,t,e)=>function(o){return n(t,e,o)})(n,t,o)},r=async function(t,e,o){let r=t.next();if(r.done)return o;for(;!r.done;)o=e(o,r.value),n(o)&&(o=await o),r=t.next();return o},u=Symbol.iterator,f=Symbol.asyncIterator,c=function(n,t,o){return t==e?((n,t)=>function(e){return n(e,t)})(n,o):((n,t)=>function(e){return n(t,e)})(n,t)},i=function(n,t,o,r,u){return t==e?((n,t,e,o)=>function(r){return n(r,t,e,o)})(n,o,r,u):o==e?((n,t,e,o)=>function(r){return n(t,r,e,o)})(n,t,r,u):r==e?((n,t,e,o)=>function(r){return n(t,e,r,o)})(n,t,o,u):((n,t,e,o)=>function(r){return n(t,e,o,r)})(n,t,o,r)},s=async function(t,e,o,r){const u=t.length;for(;++r<u;)o=e(o,t[r],r,t),n(o)&&(o=await o);return o},l=Object.keys,a=async function(t,e,o,r,u){const f=r.length;for(;++u<f;){const f=r[u];o=e(o,t[f],f,t),n(o)&&(o=await o)}return o},h=async function(t,e,o,r){for(const[u,f]of r)o=e(o,f,u,t),n(o)&&(o=await o);return o},p=function(p,d,y){return t(p)?function(t,o,r){const u=t.length;let f=-1;for(void 0===r&&(r=t[++f]);++f<u;)if(r=o(r,t[f],f,t),n(r))return r.then(i(s,t,o,e,f));return r}(p,d,y):null==p?void 0===y?c(d,p,e):d(y,p):p.constructor==Map?function(t,o,r){const u=t.entries();if(void 0===r){const n=u.next();if(n.done)return r;r=n.value[1]}for(const[f,c]of u)if(r=o(r,c,f,t),n(r))return r.then(i(h,t,o,e,u));return r}(p,d,y):"function"==typeof p[u]?function(t,u,f){let c=t.next();if(c.done)return f;for(void 0===f&&(f=c.value,c=t.next());!c.done;){if(f=u(f,c.value),n(f))return f.then(o(r,t,u,e));c=t.next()}return f}(p[u](),d,y):"function"==typeof p[f]?async function(n,t,e){let o=await n.next();if(o.done)return e;for(void 0===e&&(e=o.value,o=await n.next());!o.done;)e=await t(e,o.value),o=await n.next();return e}(p[f](),d,y):"function"==typeof p.reduce?p.reduce(d,y):"function"==typeof p.chain?p.chain(c(d,y,e)):"function"==typeof p.flatMap?p.flatMap(c(d,y,e)):p.constructor==Object?function(t,o,r){const u=l(t),f=u.length;let c=-1;for(void 0===r&&(r=t[u[++c]]);++c<f;){const f=u[c];if(r=o(r,t[f],f,t),n(r))return r.then((i=a,h=o,p=e,d=u,y=c,(s=t)==e?((n,t,e,o,r)=>function(u){return n(u,t,e,o,r)})(i,h,p,d,y):h==e?((n,t,e,o,r)=>function(u){return n(t,u,e,o,r)})(i,s,p,d,y):p==e?((n,t,e,o,r)=>function(u){return n(t,e,u,o,r)})(i,s,h,d,y):d==e?((n,t,e,o,r)=>function(u){return n(t,e,o,u,r)})(i,s,h,p,y):((n,t,e,o,r)=>function(u){return n(t,e,o,r,u)})(i,s,h,p,d)))}var i,s,h,p,d,y;return r}(p,d,y):void 0===y?c(d,p,e):d(y,p)},d=function(n,t){return n.push(t),n},y=Promise.race.bind(Promise),g=n=>new Promise((t=>{setTimeout(t,n)})),v=n=>function(){return n},b=(n,t)=>t,w=n=>n,x=Promise.all.bind(Promise),M=(n,t)=>function(...e){return t(n(...e))},j=async function(t,e){const o=[];for await(const r of t){const t=e(r);n(t)&&o.push(t)}return 0==o.length?t:x(o).then(v(t))},m=function(o){const r=o.length,i=[],s=[];let l=-1;for(;++l<r;){const r=o[l];if(t(r)){const n=r.length;let t=-1;for(;++t<n;)s.push(r[t])}else if(null==r)s.push(r);else if("function"==typeof r.then)i.push(r.then(c(d,s,e)));else if("function"==typeof r[u])for(const n of r)s.push(n);else if("function"==typeof r[f])i.push(j(r[f](),c(d,s,e)));else if("function"==typeof r.chain){const t=r.chain(w);n(t)?i.push(t.then(c(d,s,e))):s.push(t)}else if("function"==typeof r.flatMap){const t=r.flatMap(w);n(t)?i.push(t.then(c(d,s,e))):s.push(t)}else if("function"==typeof r.reduce){const t=r.reduce(M(b,c(d,s,e)),null);n(t)&&i.push(t)}else if(r.constructor==Object)for(const n in r)s.push(r[n]);else s.push(r)}return 0==i.length?s:x(i).then(v(s))},S=function(t,e){const o=t.length,r=Array(o);let u=-1,f=!1;for(;++u<o;){const o=e(t[u],u,t);n(o)&&(f=!0),r[u]=o}return f?x(r):r},A=t=>new Promise((t=>function(e){const o={};let r=0;for(const u in t){const f=t[u];n(f)?(r+=1,f.then((n=>function(t){o[n]=t,r-=1,0==r&&e(o)})(u))):o[u]=f}0==r&&e(o)})(t)),O=Object.assign,I=function(t){const o=[],r={},i=c(O,r,e),s=M(b,i);for(const e in t){const c=t[e];if(null!=c)if("function"==typeof c[u])for(const n of c)O(r,n);else if("function"==typeof c[f])o.push(j(c[f](),i));else if("function"==typeof c.chain){const t=c.chain(w);n(t)?o.push(t.then(i)):O(r,t)}else if("function"==typeof c.flatMap){const t=c.flatMap(w);n(t)?o.push(t.then(i)):i(t)}else if("function"==typeof c.reduce){const t=c.reduce(s,null);n(t)&&o.push(t)}else O(r,c)}return 0==o.length?r:x(o).then((()=>r))},P=function(t,e){const o=function(t,e){const o={};let r=!1;for(const u in t){const f=e(t[u],u,t);n(f)&&(r=!0),o[u]=f}return r?A(o):o}(t,e);return n(o)?o.then(I):I(o)},D=(n,t,e)=>n[t](e),z=function(r){r.size;const c=[],i=new Set,s=(n,t)=>i.add(t),l=o(D,i,"add",e);for(const e of r)if(t(e)){const n=e.length;let t=-1;for(;++t<n;)i.add(e[t])}else if(null==e)i.add(e);else if("function"==typeof e[u])for(const n of e)i.add(n);else if("function"==typeof e[f])c.push(j(e[f](),l));else if("function"==typeof e.chain){const t=e.chain(w);n(t)?c.push(t.then(l)):i.add(t)}else if("function"==typeof e.flatMap){const t=e.flatMap(w);n(t)?c.push(t.then(l)):i.add(t)}else if("function"==typeof e.reduce){const t=e.reduce(s,null);n(t)&&c.push(t)}else if(e.constructor==Object)for(const n in e)i.add(e[n]);else i.add(e);return 0==c.length?i:x(c).then((()=>i))},T=function(t,r){const u=function(t,r){const u=new Set,f=[];for(const c of t){const i=r(c,c,t);n(i)?f.push(i.then(o(D,u,"add",e))):u.add(i)}return 0==f.length?u:x(f).then(v(u))}(t,r);return n(u)?u.then(z):z(u)},k=(F=m,q=c(((n,t)=>n.join(t)),e,""),function(...t){const e=F(...t);return n(e)?e.then(q):q(e)});var F,q;const B=function(r,c){if(t(r))return function(t,e){const o=S(t,e);return n(o)?o.then(m):m(o)}(r,c);if(null==r)return c(r);if("function"==typeof r.then)return r.then(c);if("function"==typeof r.next)return u in r?function(n,t){let e=[],o=0;return{[u](){return this},next(){if(o<e.length){const n=e[o];return o+=1,{value:n,done:!1}}const r=n.next();if(r.done)return r;const u=p(t(r.value),d,[]);return u.length>1&&(e=u,o=1),{value:u[0],done:!1}}}}(r,c):function(t,r){const u=[],c=new Set;return{isAsyncIteratorDone:!1,[f](){return this},toString:()=>"[object FlatMappingAsyncIterator]",async next(){for(;!this.isAsyncIteratorDone||u.length>0||c.size>0;){if(!this.isAsyncIteratorDone){const{value:f,done:i}=await t.next();if(i)this.isAsyncIteratorDone=i;else{const t=r(f);if(n(t)){const n=t.then(o(p,e,d,u)).then((()=>c.delete(n)));c.add(n)}else{const e=p(t,d,u);if(n(e)){const n=e.then((()=>c.delete(n)));c.add(n)}}}}if(u.length>0)return{value:u.shift(),done:!1};c.size>0&&await y([g(1e3),...c])}return{value:void 0,done:!0}}}}(r,c);if("function"==typeof r.chain)return r.chain(c);if("function"==typeof r.flatMap)return r.flatMap(c);const i=r.constructor;return i==Object?P(r,c):i==Set?T(r,c):"string"==typeof r||i==String?function(t,e){const o=S(t,e);return n(o)?o.then(k):k(o)}(r,c):c(r)};return(t,o)=>"function"==typeof t?c(B,e,t):n(t)?t.then(c(B,e,o)):B(t,o)}());
|
package/dist/flatMap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -809,15 +809,13 @@ const _flatMap = function (value, flatMapper) {
|
|
|
809
809
|
return flatMapper(value)
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
-
const flatMap = (
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
return curry2(_flatMap, __, flatMapper)
|
|
812
|
+
const flatMap = (arg0, arg1) => {
|
|
813
|
+
if (typeof arg0 == 'function') {
|
|
814
|
+
return curry2(_flatMap, __, arg0)
|
|
816
815
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
: _flatMap(args[0], flatMapper)
|
|
816
|
+
return isPromise(arg0)
|
|
817
|
+
? arg0.then(curry2(_flatMap, __, arg1))
|
|
818
|
+
: _flatMap(arg0, arg1)
|
|
821
819
|
}
|
|
822
820
|
|
|
823
821
|
export default flatMap
|
package/dist/forEach.es.js
CHANGED
package/dist/forEach.es.min.js
CHANGED
package/dist/forEach.js
CHANGED
package/dist/forEach.min.js
CHANGED
package/dist/forEach.mjs
CHANGED
package/dist/get.es.js
CHANGED
package/dist/get.es.min.js
CHANGED
package/dist/get.js
CHANGED
package/dist/get.min.js
CHANGED
package/dist/get.mjs
CHANGED
package/dist/gt.es.js
CHANGED
package/dist/gt.es.min.js
CHANGED
package/dist/gt.js
CHANGED
package/dist/gt.min.js
CHANGED
package/dist/gt.mjs
CHANGED
package/dist/gte.es.js
CHANGED
package/dist/gte.es.min.js
CHANGED
package/dist/gte.js
CHANGED
package/dist/gte.min.js
CHANGED
package/dist/gte.mjs
CHANGED
package/dist/lt.es.js
CHANGED
package/dist/lt.es.min.js
CHANGED
package/dist/lt.js
CHANGED
package/dist/lt.min.js
CHANGED
package/dist/lt.mjs
CHANGED
package/dist/lte.es.js
CHANGED
package/dist/lte.es.min.js
CHANGED
package/dist/lte.js
CHANGED
package/dist/lte.min.js
CHANGED
package/dist/lte.mjs
CHANGED
package/dist/map.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -480,17 +480,13 @@ const _map = function (value, mapper) {
|
|
|
480
480
|
return mapper(value)
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
-
const map = (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return curry2(_map, __, mapper)
|
|
483
|
+
const map = function (arg0, arg1) {
|
|
484
|
+
if (typeof arg0 == 'function') {
|
|
485
|
+
return curry2(_map, __, arg0)
|
|
487
486
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
return collection.then(curry2(_map, __, mapper))
|
|
492
|
-
}
|
|
493
|
-
return _map(collection, mapper)
|
|
487
|
+
return isPromise(arg0)
|
|
488
|
+
? arg0.then(curry2(_map, __, arg1))
|
|
489
|
+
: _map(arg0, arg1)
|
|
494
490
|
}
|
|
495
491
|
|
|
496
492
|
// _mapEntries(value Object|Map, mapper function) -> Object|Map
|
|
@@ -507,17 +503,13 @@ const _mapEntries = (value, mapper) => {
|
|
|
507
503
|
throw new TypeError('value is not an Object or Map')
|
|
508
504
|
}
|
|
509
505
|
|
|
510
|
-
map.entries = function mapEntries(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return curry2(_mapEntries, __, mapper)
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const collection = args[0]
|
|
517
|
-
if (isPromise(collection)) {
|
|
518
|
-
return collection.then(curry2(_mapEntries, __, mapper))
|
|
506
|
+
map.entries = function mapEntries(arg0, arg1) {
|
|
507
|
+
if (typeof arg0 == 'function') {
|
|
508
|
+
return curry2(_mapEntries, __, arg0)
|
|
519
509
|
}
|
|
520
|
-
return
|
|
510
|
+
return isPromise(arg0)
|
|
511
|
+
? arg0.then(curry2(_mapEntries, __, arg1))
|
|
512
|
+
: _mapEntries(arg0, arg1)
|
|
521
513
|
}
|
|
522
514
|
|
|
523
515
|
map.series = mapper => function mappingInSeries(value) {
|
package/dist/map.es.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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},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))},mapSet=function(r,t,n){return r.set(t,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=(
|
|
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},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))},mapSet=function(r,t,n){return r.set(t,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)},map.series=r=>function(t){if(isArray(t))return arrayMapSeries(t,r);throw new TypeError(`${t} is not an Array`)},map.pool=(r,t)=>function(n){if(isArray(n))return arrayMapPool(n,t,r);throw new TypeError(`${n} is not an Array`)};export default map;
|
package/dist/map.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rubico v2.4.
|
|
2
|
+
* rubico v2.4.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.
|
|
@@ -486,17 +486,13 @@ const _map = function (value, mapper) {
|
|
|
486
486
|
return mapper(value)
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
-
const map = (
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return curry2(_map, __, mapper)
|
|
489
|
+
const map = function (arg0, arg1) {
|
|
490
|
+
if (typeof arg0 == 'function') {
|
|
491
|
+
return curry2(_map, __, arg0)
|
|
493
492
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
return collection.then(curry2(_map, __, mapper))
|
|
498
|
-
}
|
|
499
|
-
return _map(collection, mapper)
|
|
493
|
+
return isPromise(arg0)
|
|
494
|
+
? arg0.then(curry2(_map, __, arg1))
|
|
495
|
+
: _map(arg0, arg1)
|
|
500
496
|
}
|
|
501
497
|
|
|
502
498
|
// _mapEntries(value Object|Map, mapper function) -> Object|Map
|
|
@@ -513,17 +509,13 @@ const _mapEntries = (value, mapper) => {
|
|
|
513
509
|
throw new TypeError('value is not an Object or Map')
|
|
514
510
|
}
|
|
515
511
|
|
|
516
|
-
map.entries = function mapEntries(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return curry2(_mapEntries, __, mapper)
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const collection = args[0]
|
|
523
|
-
if (isPromise(collection)) {
|
|
524
|
-
return collection.then(curry2(_mapEntries, __, mapper))
|
|
512
|
+
map.entries = function mapEntries(arg0, arg1) {
|
|
513
|
+
if (typeof arg0 == 'function') {
|
|
514
|
+
return curry2(_mapEntries, __, arg0)
|
|
525
515
|
}
|
|
526
|
-
return
|
|
516
|
+
return isPromise(arg0)
|
|
517
|
+
? arg0.then(curry2(_mapEntries, __, arg1))
|
|
518
|
+
: _mapEntries(arg0, arg1)
|
|
527
519
|
}
|
|
528
520
|
|
|
529
521
|
map.series = mapper => function mappingInSeries(value) {
|