-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIArray.min.js
More file actions
1 lines (1 loc) · 1.46 KB
/
IArray.min.js
File metadata and controls
1 lines (1 loc) · 1.46 KB
1
!function(r,t){"function"==typeof define&&define.amd?define(t):"object"==typeof eki&&eki.def?eki.def("IArray",t):"object"==typeof exports?module.exports=t():r.IArray=t()}(this,function(){"use strict";function r(){for(var r=this.toArray(),t=0;t<arguments.length;t++){var e=arguments[t];r=r.concat(e&&e.isIArray?e.toArray():e)}return c(r)}function t(r,t){var e=o(this);return e[r]=t,i(e)}function e(r){var t=o(this),e=Array.prototype.splice.call(t,r,1);return t.ret=e[0],i(t)}function n(r){var t=this.indexOf(r);if(t>=0)return this.rmAt(t);var e=o(this);return e.ret=void 0,i(e)}function i(r){return("SHALLOW"===c.freeze||"DEEP"===c.freeze)&&(Object.freeze(r),"DEEP"===c.freeze&&Object.getOwnPropertyNames(r).forEach(function(t){"object"!=typeof r[t]&&"function"!=typeof r[t]||Object.isFrozen(r[t])||i(r[t])})),r}function o(r){return Object.assign(Object.create(f),r,r?{length:r.length}:null)}function c(r){return i(o(r))}var u=["filter","map","slice"].reduce(function(r,t){return r[t]=function(){return c(Array.prototype[t].apply(this,arguments))},r},{}),a=["copyWithin","fill","push","pop","reverse","shift","unshift","sort","splice"].reduce(function(r,t){return r[t]=function(){var r=o(this),e=Array.prototype[t].apply(r,arguments);return Array.isArray(e)&&(e=c(e)),r.ret=e,i(r)},r},{}),f=Object.assign(Object.create(Array.prototype),u,a,{concat:r,isIArray:!0,set:t,rm:n,rmAt:e,toJSON:function(){return this.toArray()},toArray:function(){return Array.prototype.slice.call(this)}});return c});