@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 3.59 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../assert/is-array.js";import e from"./../assert/is-nonnegative-integer.js";import t from"./../constants/math/float64-pinf.js";import n from"./../assert/has-own-property.js";import o from"./../assert/is-buffer.js";import a from"./../assert/is-error.js";import i from"./type-of.js";import f from"./regexp-from-string.js";import s from"./index-of.js";import u from"./keys.js";import m from"./property-names.js";import p from"./property-descriptor.js";import c from"./get-prototype-of.js";import l from"./define-property.js";import j from"./../buffer/from-buffer.js";import y from"./../array/int8.js";import b from"./../array/uint8.js";import v from"./../array/uint8c.js";import g from"./../array/int16.js";import w from"./../array/uint16.js";import h from"./../array/int32.js";import O from"./../array/uint32.js";import d from"./../array/float32.js";import x from"./../array/float64.js";var z,E=y,k=b,S=v,A=g,F=w,D=h,M=O,P=d,T=x;function V(r){return new E(r)}function q(r){return new k(r)}function B(r){return new S(r)}function C(r){return new A(r)}function G(r){return new F(r)}function H(r){return new D(r)}function I(r){return new M(r)}function J(r){return new P(r)}function K(r){return new T(r)}function L(){return{int8array:V,uint8array:q,uint8clampedarray:B,int16array:C,uint16array:G,int32array:H,uint32array:I,float32array:J,float64array:K}}var N=z=L(),Q=n,R=r,U=o,W=a,X=i,Y=f,Z=s,$=u,_=m,rr=p,er=c,tr=l,nr=j,or=N;function ar(r){var e,t,n,o,a,i,f,s;for(e=[],o=[],f=Object.create(er(r)),e.push(r),o.push(f),t=_(r),s=0;s<t.length;s++)n=t[s],a=rr(r,n),Q(a,"value")&&(i=R(r[n])?[]:{},a.value=fr(r[n],i,e,o,-1)),tr(f,n,a);return Object.isExtensible(r)||Object.preventExtensions(f),Object.isSealed(r)&&Object.seal(f),Object.isFrozen(r)&&Object.freeze(f),f}function ir(r){var e,t,n,o,a,i,f=[],s=[];for(a=new r.constructor(r.message),f.push(r),s.push(a),r.stack&&(a.stack=r.stack),r.code&&(a.code=r.code),r.errno&&(a.errno=r.errno),r.syscall&&(a.syscall=r.syscall),e=$(r),i=0;i<e.length;i++)o=e[i],t=rr(r,o),Q(t,"value")&&(n=R(r[o])?[]:{},t.value=fr(r[o],n,f,s,-1)),tr(a,o,t);return a}function fr(r,e,t,n,o){var a,i,f,s,u,m,p,c,l,j;if(o-=1,"object"!=typeof r||null===r)return r;if(U(r))return nr(r);if(W(r))return ir(r);if("date"===(f=X(r)))return new Date(+r);if("regexp"===f)return Y(r.toString());if("set"===f)return new Set(r);if("map"===f)return new Map(r);if("string"===f||"boolean"===f||"number"===f)return r.valueOf();if(u=or[f])return u(r);if("array"!==f&&"object"!==f)return"function"==typeof Object.freeze?ar(r):{};if(i=$(r),o>0)for(a=f,j=0;j<i.length;j++)c=r[m=i[j]],f=X(c),"object"!=typeof c||null===c||"array"!==f&&"object"!==f||U(c)?"object"===a?(s=rr(r,m),Q(s,"value")&&(s.value=fr(c)),tr(e,m,s)):e[m]=fr(c):-1===(l=Z(t,c))?(p=R(c)?new Array(c.length):{},t.push(c),n.push(p),"array"===a?e[m]=fr(c,p,t,n,o):(s=rr(r,m),Q(s,"value")&&(s.value=fr(c,p,t,n,o)),tr(e,m,s))):e[m]=n[l];else if("array"===f)for(j=0;j<i.length;j++)e[m=i[j]]=r[m];else for(j=0;j<i.length;j++)m=i[j],s=rr(r,m),tr(e,m,s);return Object.isExtensible(r)||Object.preventExtensions(e),Object.isSealed(r)&&Object.seal(e),Object.isFrozen(r)&&Object.freeze(e),e}var sr=r,ur=e.isPrimitive,mr=t,pr=fr;function cr(r,e){var t;if(arguments.length>1){if(!ur(e))throw new TypeError("invalid argument. `level` must be a nonnegative integer. Value: `"+e+"`.");if(0===e)return r}else e=mr;return t=sr(r)?new Array(r.length):{},pr(r,t,[r],[t],e)}var lr=cr;export default lr;
//# sourceMappingURL=copy.js.map