UNPKG

@minionorg/share

Version:
2 lines (1 loc) 2.25 kB
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.index={}))})(this,function(n){"use strict";function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}function o(e){if(!e)throw new SyntaxError("type is must");return function(r){return Object.prototype.toString.call(r)===`[object ${i(e)}]`}}function s(e,r,t){if(!o("Array")(e))throw new TypeError("The list must be array");if(t===void 0)e.push(r);else if(o("Number")(t))e.splice(t,0,r);else throw new TypeError("The index must be number");return e}function f(e,...r){const t=o("Array");if(t(e)){if(r.length===0)return[...e];let u=[...e];for(const l of r){if(!t(l))throw new SyntaxError(`The ${l} must be array in rest`);u=[...u,...l]}return u}else throw new SyntaxError("The ary must be array")}function h(e){if(!e)throw new SyntaxError("type is must");return function(r){return Object.prototype.toString.call(r)===`[object ${i(e)}]`}}h("Function"),h("Object");function c(e){if(e===null)return null;if(!o("Array")(e))throw new TypeError("The ary must be array");return[...e]}function w(e,r){if(!o("Array")(e))throw new TypeError("The list must be array");if(e.length===0)return e;if(r===void 0)throw new SyntaxError("The index must be required");if(o("Number")(r))r<0?r=0:r>=e.length?r=e.length-1:r=Math.floor(r);else throw new TypeError("The index must be number");return e.splice(r,1),e}function b(e,r,t){if(!o("Array")(e))throw new TypeError("The list must be array");const u=[...e];if(t===void 0)u.push(r);else if(o("Number")(t))u.splice(t,0,r);else throw new TypeError("The index must be number");return u}function m(e,r){if(!o("Array")(e))throw new TypeError("The list must be array");const t=[...e];if(t.length===0)return t;if(r===void 0)throw new SyntaxError("The index must be required");if(o("Number")(r))r<0?r=0:r>=t.length?r=t.length-1:r=Math.floor(r);else throw new TypeError("The index must be number");return t.splice(r,1),t}const T={add:s,addAll:f,clone:c,remove:w,toAdded:b,toRemoved:m};n.add=s,n.addAll=f,n.clone=c,n.default=T,n.remove=w,n.toAdded=b,n.toRemoved=m,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});