UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 3.15 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import r from"./../utils/define-nonenumerable-read-only-property.js";import e from"./../assert/is-string.js";import t from"./../assert/is-nonnegative-integer.js";import i from"./../assert/is-collection.js";import n from"./../assert/is-typed-array-like.js";import a from"./../assert/is-arraybuffer.js";import o from"./../utils/define-nonenumerable-read-only-accessor.js";import s from"./typed-ctors.js";import l from"./../utils/copy.js";import f from"./buffer.js";import u from"./../math/base/special/ceil.js";import m from"./../math/base/special/floor.js";import h from"./../math/base/special/ceil2.js";import p from"./../math/base/special/log2.js";import g from"./../math/base/special/min.js";import c from"./../assert/is-plain-object.js";import y from"./../assert/has-own-property.js";var v=9007199254740992,b={highWaterMark:v},j=c,d=y,w=t.isPrimitive;function k(r,e){return j(e)?d(e,"highWaterMark")&&(r.highWaterMark=e.highWaterMark,!w(r.highWaterMark))?new TypeError("invalid option. `highWaterMark` option must be a nonnegative integer. Option: `"+r.highWaterMark+"`."):null:new TypeError("invalid argument. Options must be an object. Value: `"+e+"`.")}function M(r){var e,t;for(e=[],t=0;t<r+1;t++)e.push([]);return e}var W=8,E=4,T=2,V=4,P=1,L=2,O=4,x=1,z=1,F={float64:W,float32:E,int16:T,int32:V,int8:P,uint16:L,uint32:O,uint8:x,uint8c:z},q=e.isPrimitive,A=t.isPrimitive,B=i,C=n,D=a,G=r,H=o,I=s,J=l,K=f,N=u,Q=m,R=h,S=p,U=g,X=b,Y=k,Z=M,$=F;function _(r){var e,t,i,n;if(i=J(X),arguments.length&&(n=Y(i,r)))throw n;return t=Z(N(S(i.highWaterMark))),e=0,G(l,"malloc",l),G(l,"calloc",f),G(l,"free",u),G(l,"clear",m),G(l,"highWaterMark",i.highWaterMark),H(l,"nbytes",a),l;function a(){return e}function o(r){var n,a;return(a=S(r))<t.length&&t[a].length?t[a].pop():e+r>i.highWaterMark?null:(n=new K(r),e+=r,n)}function s(r,e,t){var i;return 0===e?new r(0):null===(i=o(R(e)*$[t]))?i:new r(i,0,e)}function l(){var r,e,t,i,n,a,o;if(e=(r=arguments.length)&&q(arguments[r-1])?arguments[r-=1]:"float64",null===(t=I(e)))throw new TypeError("invalid argument. Must provide a recognized data type. Value: `"+e+"`.");if(r<=0)return new t(0);if(A(arguments[0]))return s(t,arguments[0],e);if(B(arguments[0])){if(null===(a=s(t,i=(n=arguments[0]).length,e)))return a;for(o=0;o<i;o++)a[o]=n[o];return a}throw new TypeError("invalid argument. First argument must be either an array length or an array-like object. Value: `"+arguments[0]+"`.")}function f(){var r,e,t;if(null!==(e=0===(r=arguments.length)?l():1===r?l(arguments[0]):l(arguments[0],arguments[1])))for(t=0;t<e.length;t++)e[t]=0;return e}function u(r){var e,i,n;if(C(r)&&r.buffer)r=r.buffer;else if(!D(r))throw new TypeError("invalid argument. Must provide a typed array or typed array buffer. Value: `"+r+"`.");if(r.byteLength>0){for(e=Q(S(r.byteLength)),e=U(t.length-1,e),i=t[e],n=0;n<i.length;n++)if(i[n]===r)return!1;i.push(r)}return!0}function m(){var r;for(r=0;r<t.length;r++)t[r].length=0;e=0}}var rr=_,er=rr(),tr=r,ir=er,nr=_;tr(ir,"factory",nr);export default ir; //# sourceMappingURL=pool.js.map