@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.37 kB
JavaScript
// 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"./../../utils/constant-function.js";import o from"./../../utils/noop.js";import i from"./../../utils/copy.js";import s from"./../../assert/is-number.js";import a from"./../../assert/is-plain-object.js";import u from"./../../assert/is-nonnegative-integer.js";import m from"./../../assert/has-own-property.js";import l from"./../../constants/math/float64-max.js";import f from"./../base/discrete-uniform.js";import p from"./../../symbol/iterator.js";var g=e,d=t,c=r,h=n,b=o,j=i,v=s.isPrimitive,y=a,w=u.isPrimitive,P=m,L=l,R=f.factory,G=p;function N(e,t,r){var n,o,i,s,a;if(!v(e))throw new TypeError("invalid argument. First argument must be an integer. Value: `"+e+"`.");if(!v(t))throw new TypeError("invalid argument. Second argument must be an integer. Value: `"+t+"`.");if(e>t)throw new RangeError("invalid argument. Minimum support `a` must be less than or equal to maximum support `b`. Value: `["+e+","+t+"]`.");if(arguments.length>2){if(!y(r))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(n=j(r,1),P(n,"iter")){if(!w(n.iter))throw new TypeError("invalid option. `iter` option must be a nonnegative integer. Option: `"+n.iter+"`.")}else n.iter=L;i=R(e,t,n),void 0===n.prng&&!1!==n.copy&&(n.state=i.state)}else i=R(e,t),n={iter:L,state:i.state};return a=0,g(o={},"next",u),g(o,"return",m),n&&n.prng?(g(o,"seed",null),g(o,"seedLength",null),c(o,"state",h(null),b),g(o,"stateLength",null),g(o,"byteLength",null)):(d(o,"seed",f),d(o,"seedLength",p),c(o,"state",T,V),d(o,"stateLength",E),d(o,"byteLength",x)),g(o,"PRNG",i.PRNG),G&&g(o,G,l),o;function u(){return a+=1,s||a>n.iter?{done:!0}:{value:i(),done:!1}}function m(e){return s=!0,arguments.length?{value:e,done:!0}:{done:!0}}function l(){return N(e,t,n)}function f(){return i.PRNG.seed}function p(){return i.PRNG.seedLength}function E(){return i.PRNG.stateLength}function x(){return i.PRNG.byteLength}function T(){return i.PRNG.state}function V(e){i.PRNG.state=e}}var E=N;export default E;
//# sourceMappingURL=discrete-uniform.js.map