@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 3.12 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 n 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";import g from"./../../math/base/special/sqrt.js";var d=l.isPrimitive,c=f;function b(e,n,r){return!d(e)||c(e)?new TypeError("invalid argument. First argument must be a number primitive and not `NaN`. Value: `"+e+"`."):!d(n)||c(n)?new TypeError("invalid argument. Second argument must be a number primitive and not `NaN`. Value: `"+n+"`."):!d(r)||c(r)?new TypeError("invalid argument. Third argument must be a number primitive and not `NaN`. Value: `"+r+"`."):e<=r&&r<=n?null:new RangeError("invalid arguments. The condition `a <= c <= b` must be satisfied. Value: `["+e+","+n+","+r+"]`.")}var h=g;function v(e,n,r,t){var o,i;return o=(t-n)/(r-n),(i=e())<o?n+h((r-n)*(t-n)*i):r-h((r-n)*(r-t)*(1-i))}var j=e,y=n,w=r,N=t,E=o,L=i,T=a,O=s,V=u.factory,P=m,R=p,G=b,S=v;function A(){var e,n,r,t,o,i,a;if(0===arguments.length)n=V();else if(1===arguments.length){if(!N(e=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");if(L(e,"prng")){if(!E(e.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+e.prng+"`.");n=e.prng}else n=V(e)}else{if(t=G(o=arguments[0],i=arguments[1],a=arguments[2]))throw t;if(arguments.length>3){if(!N(e=arguments[3]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");if(L(e,"prng")){if(!E(e.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+e.prng+"`.");n=e.prng}else n=V(e)}else n=V()}return j(r=void 0===o?c:d,"NAME","triangular"),e&&e.prng?(j(r,"seed",null),j(r,"seedLength",null),w(r,"state",T(null),O),j(r,"stateLength",null),j(r,"byteLength",null),j(r,"toJSON",T(null)),j(r,"PRNG",n)):(y(r,"seed",s),y(r,"seedLength",u),w(r,"state",l,f),y(r,"stateLength",m),y(r,"byteLength",p),j(r,"toJSON",g),j(r,"PRNG",n),n=n.normalized),r;function s(){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 g(){var e={type:"PRNG"};return e.name=r.NAME,e.state=R(n.state),e.params=void 0===o?[]:[o,i,a],e}function d(){return S(n,o,i,a)}function c(e,r,t){return P(e)||P(r)||P(t)||!(e<=t&&t<=r)?NaN:S(n,e,r,t)}}var J=A,M=J(),q=e,x=M,z=A;q(x,"factory",z);export default x;
//# sourceMappingURL=triangular.js.map