array.js 2.7 KB

1234567
  1. //>>built
  2. (function(f){"object"===typeof module&&"object"===typeof module.exports?(f=f(require,exports),void 0!==f&&(module.exports=f)):"function"===typeof define&&define.amd&&define("require exports tslib ./global ./iterator ./number ./support/has ./support/util".split(" "),f)})(function(f,g){Object.defineProperty(g,"__esModule",{value:!0});var r=f("tslib"),h=f("./global"),n=f("./iterator"),q=f("./number"),p=f("./support/has");f=f("./support/util");if(p.default("es6-array")&&p.default("es6-array-fill"))g.from=
  3. h.default.Array.from,g.of=h.default.Array.of,g.copyWithin=f.wrapNative(h.default.Array.prototype.copyWithin),g.fill=f.wrapNative(h.default.Array.prototype.fill),g.find=f.wrapNative(h.default.Array.prototype.find),g.findIndex=f.wrapNative(h.default.Array.prototype.findIndex);else{var m=function(a){if(isNaN(a))return 0;a=Number(a);isFinite(a)&&(a=Math.floor(a));return Math.min(Math.max(a,0),q.MAX_SAFE_INTEGER)},k=function(a){a=Number(a);return isNaN(a)?0:0!==a&&isFinite(a)?(0<a?1:-1)*Math.floor(Math.abs(a)):
  4. a},l=function(a,b){return 0>a?Math.max(b+a,0):Math.min(a,b)};g.from=function(a,b,c){if(null==a)throw new TypeError("from: requires an array-like object");b&&c&&(b=b.bind(c));c=m(a.length);var d="function"===typeof this?Object(new this(c)):Array(c);if(!n.isArrayLike(a)&&!n.isIterable(a))return d;if(n.isArrayLike(a)){if(0===c)return[];for(var e=0;e<a.length;e++)d[e]=b?b(a[e],e):a[e]}else{e=0;try{for(var f=r.__values(a),g=f.next();!g.done;g=f.next()){var h=g.value;d[e]=b?b(h,e):h;e++}}catch(t){k={error:t}}finally{try{g&&
  5. !g.done&&(l=f.return)&&l.call(f)}finally{if(k)throw k.error;}}}void 0!==a.length&&(d.length=c);return d;var k,l};g.of=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return Array.prototype.slice.call(a)};g.copyWithin=function(a,b,c,d){if(null==a)throw new TypeError("copyWithin: target must be an array-like object");var e=m(a.length);b=l(k(b),e);c=l(k(c),e);d=l(void 0===d?e:k(d),e);d=Math.min(d-c,e-b);e=1;b>c&&b<c+d&&(e=-1,c+=d-1,b+=d-1);for(;0<d;)c in a?a[b]=a[c]:delete a[b],
  6. b+=e,c+=e,d--;return a};g.fill=function(a,b,c,d){var e=m(a.length);c=l(k(c),e);for(d=l(void 0===d?e:k(d),e);c<d;)a[c++]=b;return a};g.find=function(a,b,c){b=g.findIndex(a,b,c);return-1!==b?a[b]:void 0};g.findIndex=function(a,b,c){var d=m(a.length);if(!b)throw new TypeError("find: second argument must be a function");c&&(b=b.bind(c));for(c=0;c<d;c++)if(b(a[c],c,a))return c;return-1}}p.default("es7-array")?g.includes=f.wrapNative(h.default.Array.prototype.includes):g.includes=function(a,b,c){void 0===
  7. c&&(c=0);var d;d=a.length;d=Number(d);isNaN(d)?d=0:(isFinite(d)&&(d=Math.floor(d)),d=Math.min(Math.max(d,0),q.MAX_SAFE_INTEGER));for(;c<d;++c){var e=a[c];if(b===e||b!==b&&e!==e)return!0}return!1}});