UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 2.58 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import i from"./../define-nonenumerable-read-only-property.js";import e from"./../../assert/is-function.js";import r from"./../../assert/is-collection.js";import t from"./../../constants/math/float64-pinf.js";import n from"./../../assert/is-plain-object.js";import o from"./../../assert/has-own-property.js";import s from"./../../assert/is-boolean.js";import l from"./../../assert/is-positive-integer.js";import a from"./../../vendor/debug.js";var m=n,u=o,c=s.isPrimitive,f=l.isPrimitive;function p(i,e){return m(e)?(u(e,"thisArg")&&(i.thisArg=e.thisArg),u(e,"series")&&(i.series=e.series,!c(i.series))?new TypeError("invalid option. `series` option must be a boolean primitive. Option: `"+i.series+"`."):u(e,"limit")&&(i.limit=e.limit,!f(i.limit))?new TypeError("invalid option. `limit` option must be a positive integer. Option: `"+i.limit+"`."):null):new TypeError("invalid argument. Options must be an object. Value: `"+e+"`.")}var g=a,d=g("reduce-right-async:limit");function h(i,e,r,t,n){var o,s,l,a,m,u;if(a=i.length,d("Collection length: %d",a),0===a)return d("Finished processing a collection."),n(null,e);for(l=a<r.limit?a:r.limit,d("Concurrency limit: %d",l),d("Number of arguments: %d",t.length),o=0,m=a,u=0;u<l;u++)m>0&&c();function c(){function n(i,r){if(!s){if(i)return s=!0,f(i);d("Accumulator: %s",JSON.stringify(r)),e=r,f()}}d("Collection element %d: %s.",m-=1,JSON.stringify(i[m])),3===t.length?t.call(r.thisArg,e,i[m],n):4===t.length?t.call(r.thisArg,e,i[m],m,n):t.call(r.thisArg,e,i[m],m,i,n)}function f(i){return i?(d("Encountered an error: %s",i.message),n(i)):(d("Processed %d of %d collection elements.",o+=1,a),m>0?c():o===a?(d("Finished processing a collection."),n(null,e)):void 0)}}var v=e,y=r,b=t,j=p,w=h;function A(i,e){var r,t,n;if(r={},arguments.length>1){if(t=j(r,i))throw t;n=e}else n=i;if(!v(n))throw new TypeError("invalid argument. Last argument must be a function. Value: `"+n+"`.");return void 0===r.series&&void 0===r.limit&&(r.series=!0),r.series?r.limit=1:r.limit||(r.limit=b),o;function o(i,e,t){if(!y(i))throw new TypeError("invalid argument. First argument must be a collection. Value: `"+i+".`");if(!v(t))throw new TypeError("invalid argument. Last argument must be a function. Value: `"+t+"`.");return w(i,e,r,n,(function(i,e){if(i)return t(i);t(null,e)}))}}var E=A;function T(i,e,r,t,n){if(arguments.length<5)return E(r)(i,e,t);E(r,t)(i,e,n)}var O=i,V=T,C=A;O(V,"factory",C);export default V; //# sourceMappingURL=reduce-right.js.map