UNPKG

16.3 kBJavaScriptView Raw
1/*!
2 * async-af/min v7.0.39
3 *
4 * AsyncAF (The asynciest of async libs there ever was or ever will be...AsyncAF!?)
5 * (https://async-af.js.org/AsyncAF)
6 *
7 * Copyright (c) 2017-present, Scott Rudiger (https://github.com/ScottRudiger)
8 *
9 * This source code is licensed under the MIT license found in this library's
10 * GitHub repository (https://github.com/AsyncAF/AsyncAF/blob/master/LICENSE).
11 */
12var t,e;t="undefined"!=typeof self?self:this,e=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=23)}([function(t,e,n){"use strict";n.d(e,"b",function(){return o}),n.d(e,"a",function(){return c});var r=n(2);const o=t=>(function e(n,r){const{length:o}=n;if(!o)return Promise.resolve(n);const c=!(r in t);return Promise.resolve(t[r]).then(t=>(c||(n[r]=t),r===o-1?n:e(n,r+1)))})(Array(t.length>>>0),0),c=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return Object(r.a)(t,t=>t).then(e?t=>Object(r.a)(Array.prototype.map.call(t,e,n)):void 0)}},function(t,e,n){"use strict";e.a=function(t){return Array.isArray(t)||null!=t&&null!=t.length}},function(t,e,n){"use strict";e.a=(t=>new Promise((e,n)=>{const r=t.length>>>0,o=Array(r);let c=r,i=r;if(!r)return e(o);const a=r=>Promise.resolve(t[r]).then(n=>{r in t&&(o[r]=n),--c||e(o)},n);for(;i--;)a(i)}))},function(t,e,n){"use strict";e.a=function(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0})}},,function(t,e,n){"use strict";var r=n(3);e.a=(t=>{const{name:e}=t,n=function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return new t(...n)};return n.prototype=t.prototype,Object.setPrototypeOf(n,t),n.prototype.constructor=n,Object(r.a)(n,e)})},function(t,e,n){"use strict";n.r(e);var r=n(5);const o=new WeakMap;var c={inSeries:{get(){return o.get(this)}},series:{get(){return o.set(this,!this.inSeries),this}},io:{get(){return this.series}}};function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,"AsyncAfWrapperProto",function(){return s});const a=new WeakMap;class s{constructor(t){a.set(this,Promise.resolve(t))}then(t,e){return this.constructor(a.get(this).then(t,e))}catch(t){return this.then(null,t)}finally(t){return a.get(this).finally(t)}}s.use=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof t)throw TypeError("prototypeMethods param accepts an Object containing the prototypeMethods you'd like to add to the AsyncAF prototype, or an empty Object");if("object"!=typeof e)throw TypeError("staticMethods param accepts an Object containing the staticMethods you'd like to add to AsyncAF");Object.assign(this.prototype,t),Object.assign(this,e)},Object.defineProperties(s.prototype,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){i(t,e,n[e])})}return t}({},c,{[Symbol.toStringTag]:{value:"AsyncAF"}}));const l=Object(r.a)(class extends s{});e.default=l},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(2),c=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("mapAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));return this.inSeries?Object(c.b)(n).then(n=>n.reduce((n,r,c,i)=>n.then(n=>(n[c]=Promise.resolve(t.call(e,r,c,i)),Object(o.a)(n))),Promise.resolve(Array(n.length>>>0)))):Object(c.a)(n,t,e)})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("forEachAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));return(this.inSeries?Object(o.b)(n).then(n=>n.reduce((n,r,o,c)=>n.then(()=>Promise.resolve(t.call(e,r,o,c))),Promise.resolve())):Object(o.a)(n,t,e)).then(()=>{})})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("filterAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));return(this.inSeries?o.b:o.a)(n).then(n=>(this.inSeries?n.reduce((n,r,o,c)=>n.then(n=>(n[o]=t.call(e,r,o,c),Promise.all(n))),Promise.all([])):Object(o.a)(n,t,e)).then(t=>n.filter((e,n)=>t[n])))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){return this.then(e=>{if(!Object(r.a)(e))throw TypeError("reduceAF cannot be called on ".concat(e,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));const n=e.length>>>0;if(!n&&1===arguments.length)throw TypeError("reduceAF cannot be called on an empty array without an initial value");if(!n)return arguments[1];const c=t=>!(t in e);let i,a=0;if(2===arguments.length)[,i]=arguments;else{for(;c(a);)a++;i=e[a++]}return(this.inSeries?o.b:o.a)(e).then(e=>{const r=(o,i)=>Promise.resolve(o).then(o=>Promise.resolve(c(i)?o:t(o,e[i],i,e)).then(t=>i===n-1?t:r(t,i+1)));return r(i,a)})})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("everyAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));const c=n.length>>>0;return this.inSeries?!c||function n(r,o){const i=!(o in r);return Promise.resolve(r[o]).then(a=>(r[o]=a,Promise.resolve(!i&&t.call(e,a,o,r)).then(t=>!(!t&&!i)&&(o===c-1||n(r,o+1)))))}(Array.prototype.slice.call(n),0):Object(o.a)(n,t,e).then(t=>t.every(Boolean))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("someAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));const c=n.length>>>0;return this.inSeries?!!c&&function n(r,o){const i=!(o in r);return Promise.resolve(r[o]).then(a=>(r[o]=a,Promise.resolve(!i&&t.call(e,a,o,r)).then(t=>!(!t||i)||o!==c-1&&n(r,o+1))))}(Array.prototype.slice.call(n),0):Object(o.a)(n,t,e).then(t=>t.some(Boolean))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("includesAF cannot be called on ".concat(n,", only on an Array, String, or array-like Object"));const c=n.length>>>0,i=0|e;return"string"==typeof n?n.includes(t,i):this.inSeries?!!c&&function e(r){return Promise.resolve(n[r]).then(n=>!!((t,e)=>t===e||Number.isNaN(t)&&Number.isNaN(e))(n,t)||!(r>=c-1)&&e(r+1))}(Math.max(i>=0?i:c-Math.abs(i),0)):Object(o.a)(n).then(e=>e.includes(t,i))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("findAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));const c=Array.from(n),i=c.length>>>0;return this.inSeries?i?function n(r,o){return Promise.resolve(r[o]).then(c=>(r[o]=c,Promise.resolve(t.call(e,c,o,r)).then(t=>t?c:o!==i-1?n(r,o+1):void 0)))}(c,0):void 0:Object(o.a)(c,t,e).then(t=>n[t.indexOf(!0)])})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("findIndexAF cannot be called on ".concat(n,", only on an Array or array-like Object"));if("function"!=typeof t)throw TypeError("".concat(t," is not a function"));const c=Array.from(n),i=c.length>>>0;return this.inSeries?i?function n(r,o){return Promise.resolve(r[o]).then(c=>(r[o]=c,Promise.resolve(t.call(e,c,o,r)).then(t=>t?o:o===i-1?-1:n(r,o+1))))}(c,0):-1:Object(o.a)(c,t,e).then(t=>t.indexOf(!0))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("indexOfAF cannot be called on ".concat(n,", only on an Array, String, or array-like Object"));const c=n.length>>>0,i=0|e;return"string"==typeof n?n.indexOf(t,i):this.inSeries?function e(r){return Promise.resolve(n[r]).then(o=>r in n&&o===t?r:r>=c-1?-1:e(r+1))}(Math.max(i>=0?i:c-Math.abs(i),0)):Object(o.a)(n).then(e=>e.indexOf(t,i))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);e.default=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if(!Object(r.a)(n))throw TypeError("lastIndexOfAF cannot be called on ".concat(n,", only on an Array, String, or array-like Object"));const c=n.length>>>0;let i=+e;return Number.isNaN(i)&&(i=c-1),"string"==typeof n?n.lastIndexOf(t,i):this.inSeries?function e(r){return Promise.resolve(n[r]).then(o=>r in n&&o===t?r:r<=0?-1:e(r-1))}(Math.min(i>=0?i:Math.max(c-Math.abs(i),0),c-1)):Object(o.a)(n).then(e=>e.lastIndexOf(t,i))})}},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0);const c=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:",";return this.then(e=>{if(!Object(r.a)(e))throw TypeError("joinAF cannot be called on ".concat(e,", only on an Array or array-like Object"));return Object(o.a)(e).then(e=>e.join(t))})};Object.defineProperty(c,"length",{value:1}),e.default=c},function(t,e,n){"use strict";n.r(e);const r=t=>Promise[Array.isArray(t)?"all":"resolve"](t);e.default=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];const o=t=>[Promise,this.constructor].some(e=>t instanceof e),c=(t,e)=>o(e)&&e.then(r).then(e=>t.concat(e))||t.concat(e);return this.then(t=>{if("string"!=typeof t&&!Array.isArray(t))throw TypeError("concatAF cannot be called on ".concat(t,", only on an Array or String"));return r(t).then(t=>e.reduce((t,e)=>o(t)?t.then(t=>c(t,e)):c(t,e),t))})}},function(t,e,n){"use strict";n.r(e),e.default=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.then(n=>{if("string"!=typeof n||Array.isArray(n))throw TypeError("splitAF may be called on a string but was called on ".concat(n));return String.prototype.split.call(n,t,e)})}},function(t,e,n){"use strict";n.r(e);function r(){const t=a(["/"]);return r=function(){return t},t}function o(){const t=a(["/"]);return o=function(){return t},t}function c(){const t=a(["/"]);return c=function(){return t},t}function i(){const t=a([":"]);return i=function(){return t},t}function a(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function s(){const t=h(["/"]);return s=function(){return t},t}function l(){const t=h(["/"]);return l=function(){return t},t}function u(){const t=h(["/"]);return u=function(){return t},t}function f(){const t=h(["\n"],["\\n"]);return f=function(){return t},t}function h(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var d=n(3);const p=function t(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];t.label&&n.unshift(t.setFormat(t.labelFormat));const o=Date.now();return Promise.all(n).then(e=>{if(t.duration){const t=((Date.now()-o)/1e3).toFixed(3);e.push("\n in ".concat(t," secs"))}t.wrappedLog("",...e)})};Object.defineProperties(p,{wrappedLog:{value:function(){console&&console.log&&console.log(...arguments)},writable:!0},wrappedWarn:{value:function(){console&&console.warn&&console.warn(...arguments)},writable:!0},setFormat:{value:t=>{const e=Error();if(!e.stack)return"";const[n]=e.stack.split(f()).filter((t,e,n)=>/logAF(?:\s+|\s+\[.+\]\s+)\(/.test(n[e?e-1:e])||/logAfStub(?:\s+|\s+\[.+\]\s+)\(/.test(n[e])),a=n.slice(n.indexOf(u())).replace(")",""),h=a.lastIndexOf(l()),d={file:()=>"@".concat(a.slice(h+1),":\n"),path:()=>"@".concat(a,":\n"),parent(){const t=a.slice(0,h).lastIndexOf(s())+1;return"@".concat(a.slice(t),":\n")},arrow:()=>"========================>"};return d[t]?d[t]():((t,e,n)=>{if("string"==typeof t)return t;let[a,s,l]=e.split(i());const u=(a=a.split(c())).pop();a=a.join(o());const f="".concat(a.split(r()).pop(),"/");return t({path:a+="/",line:s,col:l,file:u,parent:f,arrow:n})})(t,a,d.arrow())},writable:!0},options:{value:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{label:e,duration:n,labelFormat:r}=t;"boolean"==typeof e&&(y.label=e),"boolean"==typeof n&&(y.duration=n),r&&("string"==typeof r||"function"==typeof r?y.labelFormat=r:y.wrappedWarn("Warning: logAF labelFormat option must be set to 'file' (default), 'path', 'parent', 'arrow', or a custom string or function\n"))},writable:!0}}),(p.options.reset=function(){p.label=!0,p.labelFormat="file",p.duration=!0})();var y=e.default=Object(d.a)(p,"logAF")},,function(t,e,n){"use strict";n.r(e);var r=n(5),o=n(6),c=n(3),i=n(21),a=n(7),s=n(8),l=n(9),u=n(10),f=n(11),h=n(12),d=n(13),p=n(14),y=n(15),b=n(16),O=n(17),v=n(18),j=n(19),A=n(20);const m=t=>"@async-af/".concat(t.replace(/AsyncAf|AF/g,"").toLowerCase()),g="".concat("./lib/","classes/"),w=(m("AsyncAfWrapper"),[Object(c.a)(i.default,"logAF")].map(t=>[t,"".concat("./lib/","methods/other/").concat(t.name),m(t.name)])),P=[Object(c.a)(a.default,"mapAF"),Object(c.a)(s.default,"forEachAF"),Object(c.a)(l.default,"filterAF"),Object(c.a)(u.default,"reduceAF"),Object(c.a)(f.default,"everyAF"),Object(c.a)(h.default,"someAF"),Object(c.a)(d.default,"includesAF"),Object(c.a)(p.default,"findAF"),Object(c.a)(y.default,"findIndexAF"),Object(c.a)(b.default,"indexOfAF"),Object(c.a)(O.default,"lastIndexOfAF"),Object(c.a)(v.default,"joinAF"),Object(c.a)(j.default,"concatAF")].map(t=>[t,"".concat("./lib/","methods/arrays/").concat(t.name),m(t.name)]),F=[Object(c.a)(A.default,"splitAF")].map(t=>[t,"".concat("./lib/","methods/strings/").concat(t.name),m(t.name)]),x=[...P,...F],E=t=>t.map(t=>{let[e]=t;return e}),S=E(w),T=E(x);function k(){const t=(e=["AF"],n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}})));var e,n;return k=function(){return t},t}const M=Object(r.a)(class extends o.AsyncAfWrapperProto{}),W=t=>t.reduce((t,e)=>{const[n]=e.name.split(k())||[e.name];return Object.assign(t,{[e.name]:{value:e}},{[n]:{value:e}})},{});Object.defineProperties(o.AsyncAfWrapperProto,W(S)),Object.defineProperties(o.AsyncAfWrapperProto.prototype,W(T)),e.default=M}]).default},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("AsyncAF",[],e):"object"==typeof exports?exports.AsyncAF=e():t.AsyncAF=e();
13//# sourceMappingURL=min.js.map
\No newline at end of file