UNPKG

@stdlib/esm

Version:

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

3 lines 2.99 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 g from"./../../random/base/improved-ziggurat.js";var c=!0,y={copy:c},b=e,v=t,h=r,j=n,w=o.isPrimitive,L=i,T=s,E=a.isPrimitive,x=u,N=m,P=p,O=l,G=f,R=d,V=g.factory,k=y;function q(e,t,r){var n,o,i,s;if(!j(e))throw new TypeError("invalid argument. First argument must be an iterator. Value: `"+e+"`.");if(!w(t))throw new TypeError("invalid argument. Second argument must be a positive number. Value: `"+t+"`.");if(o=P(k),arguments.length>2){if(!L(r))throw new TypeError("invalid argument. Third argument must be an object. Value: `"+r+"`.");if(N(r,"copy")&&(o.copy=r.copy,!E(r.copy)))throw new TypeError("invalid option. `copy` option must be a boolean. Option: `"+r.copy+"`.");if(N(r,"prng")){if(!T(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");n=r.prng}else if(N(r,"state")){if(o.state=r.state,!x(r.state))throw new TypeError("invalid option. `state` option must be a Uint32Array. Option: `"+r.state+"`.")}else if(N(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 void 0===n&&(n=V(o)),b(i={},"next",d),b(i,"return",g),R&&T(e[R])&&b(i,R,c),r&&r.prng?(b(i,"seed",null),b(i,"seedLength",null),h(i,"state",G(null),O),b(i,"stateLength",null),b(i,"byteLength",null),b(i,"PRNG",null)):(v(i,"seed",a),v(i,"seedLength",u),h(i,"state",l,f),v(i,"stateLength",m),v(i,"byteLength",p),b(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 r,o;return s?{done:!0}:(r={},"number"==typeof(o=e.next()).value?r.value=o.value+t*n():N(o,"value")&&(r.value=NaN),o.done?(s=!0,r.done=!0):r.done=!1,r)}function g(e){return s=!0,arguments.length?{value:e,done:!0}:{done:!0}}function c(){return q(e[R](),t,o)}}var z=q;export default z; //# sourceMappingURL=awgn.js.map