@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.42 kB
JavaScript
// 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,f=s.isPrimitive,c=l.isPrimitive;function p(i,e){return m(e)?(u(e,"thisArg")&&(i.thisArg=e.thisArg),u(e,"series")&&(i.series=e.series,!f(i.series))?new TypeError("invalid option. `series` option must be a boolean primitive. Option: `"+i.series+"`."):u(e,"limit")&&(i.limit=e.limit,!c(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,h=g("for-each-right-async:limit");function d(i,e,r,t){var n,o,s,l,a,m;if(l=i.length,h("Collection length: %d",l),0===l)return h("Finished processing a collection."),t();for(s=l<e.limit?l:e.limit,h("Concurrency limit: %d",s),h("Number of arguments: %d",r.length),n=0,a=l,m=0;m<s;m++)a>0&&u();function u(){h("Collection element %d: %s.",a-=1,JSON.stringify(i[a])),2===r.length?r.call(e.thisArg,i[a],f):3===r.length?r.call(e.thisArg,i[a],a,f):r.call(e.thisArg,i[a],a,i,f)}function f(i){if(!o)return i?(o=!0,h("Encountered an error: %s",i.message),t(i)):(h("Processed %d of %d collection elements.",n+=1,l),a>0?u():n===l?(h("Finished processing a collection."),t()):void 0)}}var v=e,b=r,y=t,j=p,w=d;function E(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 r.series?r.limit=1:r.limit||(r.limit=y),o;function o(i,e){if(!b(i))throw new TypeError("invalid argument. First argument must be a collection. Value: `"+i+".`");if(!v(e))throw new TypeError("invalid argument. Last argument must be a function. Value: `"+e+"`.");return w(i,r,n,(function(i){if(i)return e(i);e()}))}}var A=E;function T(i,e,r,t){if(arguments.length<4)return A(e)(i,r);A(e,r)(i,t)}var O=i,V=T,C=E;O(V,"factory",C);export default V;
//# sourceMappingURL=for-each-right.js.map