UNPKG

@stdlib/esm

Version:

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

3 lines 2.84 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import n from"./../../utils/define-nonenumerable-read-only-property.js";import e from"./../../utils/define-nonenumerable-read-only-accessor.js";import r from"./../../utils/define-nonenumerable-read-write-accessor.js";import t from"./../../assert/is-plain-object.js";import o from"./../../assert/is-function.js";import i from"./../../assert/has-own-property.js";import a from"./../../utils/constant-function.js";import s from"./../../utils/noop.js";import u from"./mt19937.js";import m from"./../../math/base/assert/is-nan.js";import p from"./../../array/to-json.js";import l from"./../../assert/is-number.js";import f from"./../../assert/is-nan.js";var g=l.isPrimitive,d=f;function c(n,e){return!g(n)||d(n)?new TypeError("invalid argument. First argument must be a number primitive and not `NaN`. Value: `"+n+"`."):!g(e)||d(e)?new TypeError("invalid argument. Second argument must be a number primitive and not `NaN`. Value: `"+e+"`."):n>=e?new RangeError("invalid argument. Minimum support `a` must be less than maximum support `b`. Value: `["+n+","+e+"]`."):null}function b(n,e,r){var t=n();return r*t+(1-t)*e}var h=n,v=e,j=r,y=t,w=o,N=i,E=a,L=s,O=u.factory,T=m,V=p,P=c,R=b;function G(){var n,e,r,t,o,i;if(0===arguments.length)e=O();else if(1===arguments.length){if(!y(n=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+n+"`.");if(N(n,"prng")){if(!w(n.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+n.prng+"`.");e=n.prng}else e=O(n)}else{if(t=P(o=arguments[0],i=arguments[1]))throw t;if(arguments.length>2){if(!y(n=arguments[2]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+n+"`.");if(N(n,"prng")){if(!w(n.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+n.prng+"`.");e=n.prng}else e=O(n)}else e=O()}return h(r=void 0===o?d:g,"NAME","uniform"),n&&n.prng?(h(r,"seed",null),h(r,"seedLength",null),j(r,"state",E(null),L),h(r,"stateLength",null),h(r,"byteLength",null),h(r,"toJSON",E(null)),h(r,"PRNG",e)):(v(r,"seed",a),v(r,"seedLength",s),j(r,"state",p,l),v(r,"stateLength",u),v(r,"byteLength",m),h(r,"toJSON",f),h(r,"PRNG",e),e=e.normalized),r;function a(){return e.seed}function s(){return e.seedLength}function u(){return e.stateLength}function m(){return e.byteLength}function p(){return e.state}function l(n){e.state=n}function f(){var n={type:"PRNG"};return n.name=r.NAME,n.state=V(e.state),n.params=void 0===o?[]:[o,i],n}function g(){return R(e,o,i)}function d(n,r){return T(n)||T(r)||n>=r?NaN:R(e,n,r)}}var M=G,S=M(),x=n,A=S,J=G;x(A,"factory",J);export default A; //# sourceMappingURL=uniform.js.map