@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 5.17 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"./../../vendor/process.js";import r from"./../../vendor/readable-stream.js";import i from"./../../assert/is-number.js";import n from"./../../math/base/assert/is-nan.js";import o from"./../../assert/is-error.js";import s from"./../../utils/copy.js";import a from"./../../utils/inherit.js";import p from"./../../utils/define-nonenumerable-property.js";import m from"./../../utils/define-read-only-accessor.js";import u from"./../../utils/define-read-write-accessor.js";import d from"./../base/arcsine.js";import h from"./../../buffer/from-string.js";import g from"./../../assert/is-plain-object.js";import f from"./../../assert/has-own-property.js";import c from"./../../assert/is-boolean.js";import l from"./../../assert/is-nonnegative-number.js";import b from"./../../assert/is-string.js";import y from"./../../assert/is-positive-integer.js";import v from"./../../assert/is-nonnegative-integer.js";import j from"./../../vendor/debug.js";var _=!1,w=null,M="\n",E=!0,T=1e308,O={objectMode:_,encoding:w,sep:M,copy:E,siter:T},N=g,P=f,k=c.isPrimitive,L=l.isPrimitive,V=b.isPrimitive,W=y.isPrimitive,S=v.isPrimitive;function R(e,t){return N(t)?P(t,"sep")&&(e.sep=t.sep,!V(e.sep))?new TypeError("invalid option. `sep` option must be a primitive string. Option: `"+e.sep+"`."):P(t,"objectMode")&&(e.objectMode=t.objectMode,!k(e.objectMode))?new TypeError("invalid option. `objectMode` option must be a primitive boolean. Option: `"+e.objectMode+"`."):P(t,"encoding")&&(e.encoding=t.encoding,!V(e.encoding)&&null!==e.encoding)?new TypeError("invalid option. `encoding` option must be a primitive string or null. Option: `"+e.encoding+"`."):P(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!L(e.highWaterMark))?new TypeError("invalid option. `highWaterMark` option must be a nonnegative number. Option: `"+e.highWaterMark+"`."):P(t,"iter")&&(e.iter=t.iter,!S(e.iter))?new TypeError("invalid option. `iter` option must be a nonnegative integer. Option: `"+e.iter+"`."):P(t,"siter")&&(e.siter=t.siter,!W(e.siter))?new TypeError("invalid option. `siter` option must be a positive integer. Option: `"+e.siter+"`."):(P(t,"prng")&&(e.prng=t.prng),P(t,"seed")&&(e.seed=t.seed),P(t,"state")&&(e.state=t.state),P(t,"copy")&&(e.copy=t.copy),null):new TypeError("invalid argument. Options must be an object. Value: `"+t+"`.")}var x=j,G=x("random:streams:arcsine"),C=r.Readable,F=i.isPrimitive,J=n,A=o,I=s,q=a,z=p,B=e,D=m,H=u,K=d.factory,Q=h,U=O,X=R,Y=G;function Z(){return this._prng.seed}function $(){return this._prng.seedLength}function ee(){return this._prng.stateLength}function te(){return this._prng.byteLength}function re(){return this._prng.state}function ie(e){this._prng.state=e}function ne(){var e,t;if(!this._destroyed)for(e=!0;e;){if(this._i+=1,this._i>this._iter)return Y("Finished generating pseudorandom numbers."),this.push(null);t=this._prng(),Y("Generated a new pseudorandom number. Value: %d. Iter: %d.",t,this._i),!1===this._objectMode&&(t=t.toString(),t=1===this._i?Q(t):Q(this._sep+t)),e=this.push(t),this._i%this._siter==0&&this.emit("state",this.state)}}function oe(e){var r;return this._destroyed?(Y("Attempted to destroy an already destroyed stream."),this):(r=this,this._destroyed=!0,t.nextTick((function(){e&&(Y("Stream was destroyed due to an error. Error: %s.",A(e)?e.message:JSON.stringify(e)),r.emit("error",e));Y("Closing the stream..."),r.emit("close")})),this)}function se(e,t,r){var i,n;if(!(this instanceof se))return arguments.length>2?new se(e,t,r):new se(e,t);if(!F(e)||J(e))throw new TypeError("invalid argument. First argument must be a number primitive and not `NaN`. Value: `"+e+"`.");if(!F(t)||J(t))throw new TypeError("invalid argument. Second argument must be a number primitive and not `NaN`. Value: `"+t+"`.");if(e>=t)throw new RangeError("invalid argument. Minimum support `a` must be less than maximum support `b`. Value: `["+e+","+t+"]`.");if(i=I(U),arguments.length>2&&(n=X(i,r)))throw n;return Y("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),C.call(this,i),z(this,"_destroyed",!1),B(this,"_objectMode",i.objectMode),B(this,"_sep",i.sep),B(this,"_iter",i.iter),B(this,"_siter",i.siter),z(this,"_i",0),B(this,"_prng",K(e,t,i)),B(this,"PRNG",this._prng.PRNG),this}q(se,C),D(se.prototype,"seed",Z),D(se.prototype,"seedLength",$),H(se.prototype,"state",re,ie),D(se.prototype,"stateLength",ee),D(se.prototype,"byteLength",te),B(se.prototype,"_read",ne),B(se.prototype,"destroy",oe);var ae=g,pe=s,me=se;function ue(e,t,r){var i;if(arguments.length>2){if(!ae(i=r))throw new TypeError("invalid argument. Options must be an object. Value: `"+i+"`.");i=pe(r,1)}else i={};return i.objectMode=!0,new me(e,t,i)}var de=s,he=se;function ge(e,t,r){var i,n;return n=1===(i=arguments.length)?de(e,1):i>2?de(r,1):{},i<2?o:s;function o(e,t){return new he(e,t,n)}function s(){return new he(e,t,n)}}var fe=e,ce=se,le=ue,be=ge;fe(ce,"objectMode",le),fe(ce,"factory",be);export default ce;
//# sourceMappingURL=arcsine.js.map