UNPKG

@stdlib/esm

Version:

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

3 lines 2.85 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-plain-object.js";import o from"./../../assert/is-function.js";import i from"./../../assert/has-own-property.js";import s from"./../../utils/constant-function.js";import a from"./../../utils/noop.js";import u from"./mt19937.js";import m from"./../../math/base/assert/is-nan.js";import p from"./../../math/base/assert/is-positive-integer.js";import f from"./../../array/to-json.js";import l from"./../../assert/is-positive-number.js";import g from"./../../assert/is-positive-integer.js";import c from"./../../math/base/special/ln.js";var d=l.isPrimitive,b=g.isPrimitive;function v(e,t){return b(e)?d(t)?null:new TypeError("invalid argument. Second argument must be a positive number. Value: `"+t+"`."):new TypeError("invalid argument. First argument must be a positive integer. Value: `"+e+"`.")}var h=c;function j(e,t,r){var n,o;for(n=1,o=0;o<t;o++)n*=e();return-1/r*h(n)}var y=e,w=t,L=r,N=n,E=o,O=i,T=s,P=a,V=u.factory,G=m,R=p,S=f,A=v,J=j;function M(){var e,t,r,n,o,i;if(0===arguments.length)t=V();else if(1===arguments.length){if(!N(r=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(O(r,"prng")){if(!E(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");t=r.prng}else t=V(r)}else{if(o=A(i=arguments[0],e=arguments[1]))throw o;if(arguments.length>2){if(!N(r=arguments[2]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(O(r,"prng")){if(!E(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");t=r.prng}else t=V(r)}else t=V()}return y(n=void 0===i?c:g,"NAME","erlang"),r&&r.prng?(y(n,"seed",null),y(n,"seedLength",null),L(n,"state",T(null),P),y(n,"stateLength",null),y(n,"byteLength",null),y(n,"toJSON",T(null)),y(n,"PRNG",t)):(w(n,"seed",s),w(n,"seedLength",a),L(n,"state",p,f),w(n,"stateLength",u),w(n,"byteLength",m),y(n,"toJSON",l),y(n,"PRNG",t),t=t.normalized),n;function s(){return t.seed}function a(){return t.seedLength}function u(){return t.stateLength}function m(){return t.byteLength}function p(){return t.state}function f(e){t.state=e}function l(){var r={type:"PRNG"};return r.name=n.NAME,r.state=S(t.state),r.params=void 0===i?[]:[i,e],r}function g(){return J(t,i,e)}function c(e,r){return G(e)||G(r)||!R(e)||r<=0?NaN:J(t,e,r)}}var x=M,z=x(),F=e,k=z,q=M;F(k,"factory",q);export default k; //# sourceMappingURL=erlang.js.map