UNPKG

@stdlib/esm

Version:

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

3 lines 3.04 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../../utils/define-nonenumerable-read-only-property.js";import t from"./../../utils/define-nonenumerable-read-only-accessor.js";import r from"./../../utils/define-nonenumerable-read-write-accessor.js";import n from"./../../assert/is-iterator-like.js";import o from"./../../assert/is-positive-number.js";import i from"./../../assert/is-plain-object.js";import s from"./../../assert/is-function.js";import a from"./../../assert/is-boolean.js";import u from"./../../assert/is-uint32array.js";import m from"./../../assert/has-own-property.js";import p from"./../../utils/copy.js";import l from"./../../utils/noop.js";import f from"./../../utils/constant-function.js";import d from"./../../symbol/iterator.js";import c from"./../../random/base/laplace.js";import g from"./../../constants/math/float64-sqrt-two.js";var y=!0,b={copy:y},h=e,v=t,j=r,w=n,L=o.isPrimitive,T=i,E=s,x=a.isPrimitive,N=u,P=m,O=p,q=l,G=f,R=d,V=c.factory,k=g,A=b;function F(e,t,r){var n,o,i,s;if(!w(e))throw new TypeError("invalid argument. First argument must be an iterator. Value: `"+e+"`.");if(!L(t))throw new TypeError("invalid argument. Second argument must be a positive number. Value: `"+t+"`.");if(o=O(A),arguments.length>2){if(!T(r))throw new TypeError("invalid argument. Third argument must be an object. Value: `"+r+"`.");if(P(r,"copy")&&(o.copy=r.copy,!x(r.copy)))throw new TypeError("invalid option. `copy` option must be a boolean. Option: `"+r.copy+"`.");if(P(r,"prng")){if(!E(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");o.prng=r.prng}else if(P(r,"state")){if(o.state=r.state,!N(r.state))throw new TypeError("invalid option. `state` option must be a Uint32Array. Option: `"+r.state+"`.")}else if(P(r,"seed")&&(o.seed=r.seed,void 0===r.seed))throw new TypeError("invalid option. `seed` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `"+r.seed+"`.")}return n=V(0,t/k,o),h(i={},"next",d),h(i,"return",c),R&&E(e[R])&&h(i,R,g),r&&r.prng?(h(i,"seed",null),h(i,"seedLength",null),j(i,"state",G(null),q),h(i,"stateLength",null),h(i,"byteLength",null),h(i,"PRNG",r.prng)):(v(i,"seed",a),v(i,"seedLength",u),j(i,"state",l,f),v(i,"stateLength",m),v(i,"byteLength",p),h(i,"PRNG",n.PRNG)),i;function a(){return n.seed}function u(){return n.seedLength}function m(){return n.stateLength}function p(){return n.byteLength}function l(){return n.state}function f(e){n.state=e}function d(){var t,r;return s?{done:!0}:(t={},"number"==typeof(r=e.next()).value?t.value=r.value+n():P(r,"value")&&(t.value=NaN),r.done?(s=!0,t.done=!0):t.done=!1,t)}function c(e){return s=!0,arguments.length?{value:e,done:!0}:{done:!0}}function g(){return F(e[R](),t,o)}}var S=F;export default S; //# sourceMappingURL=awln.js.map