@thi.ng/random
Advanced tools
Comparing version 1.4.15 to 1.4.16
@@ -6,3 +6,3 @@ # Change Log | ||
## [1.4.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.14...@thi.ng/random@1.4.15) (2020-07-28) | ||
## [1.4.16](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.15...@thi.ng/random@1.4.16) (2020-08-16) | ||
@@ -15,42 +15,2 @@ **Note:** Version bump only for package @thi.ng/random | ||
## [1.4.14](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.13...@thi.ng/random@1.4.14) (2020-07-04) | ||
**Note:** Version bump only for package @thi.ng/random | ||
## [1.4.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.12...@thi.ng/random@1.4.13) (2020-07-02) | ||
**Note:** Version bump only for package @thi.ng/random | ||
## [1.4.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.11...@thi.ng/random@1.4.12) (2020-06-20) | ||
**Note:** Version bump only for package @thi.ng/random | ||
## [1.4.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.10...@thi.ng/random@1.4.11) (2020-06-14) | ||
**Note:** Version bump only for package @thi.ng/random | ||
## [1.4.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.9...@thi.ng/random@1.4.10) (2020-06-01) | ||
**Note:** Version bump only for package @thi.ng/random | ||
# [1.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.3.2...@thi.ng/random@1.4.0) (2020-03-01) | ||
@@ -57,0 +17,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/checks"),require("@thi.ng/api")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/checks","@thi.ng/api"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.random={}),t.thi.ng.checks,t.thi.ng.api)}(this,(function(t,e,r){"use strict";class n{float(t=1){return this.int()*(1/4294967295)*t}norm(t=1){return 2*(this.int()*(1/4294967295)-.5)*t}minmax(t,e){return this.float()*(e-t)+t}gaussian(t=10,e=-.5,r=1){let n=0,s=t;for(;s-- >0;)n+=this.float(r);return n/t+e}}const s=[3737844653,799659867,3827263459,1552149530],i=[...s,4137311345];class f extends n{constructor(t=3737844653){super(),this.buffer=new Uint32Array([t,0])}copy(){const t=new f;return t.buffer.set(this.buffer),t}seed(t){return this.buffer.set([t,0]),this}int(){const t=this.buffer,e=1540483477,r=t[1]++*e>>>0,n=t[0]=(r^r>>24^t[0]*e>>>0)*e>>>0;return(n^n>>>13)>>>0}}const u=Math.random;class o extends n{int(){return 4294967295*u()>>>0}float(t=1){return u()*t}norm(t=1){return 2*(u()-.5)*t}}const h=new o;class c extends n{constructor(t=s){super(),this.buffer=new Uint32Array(4),this.seed(t)}copy(){return new c(this.buffer)}bytes(){return new Uint8Array(this.buffer.buffer)}seed(t){return this.buffer.set(t),this}int(){const t=this.buffer;let e=t[0]+t[3];const r=(e<<7|e>>>25)>>>0;return e=t[1]<<9,t[2]^=t[0],t[3]^=t[1],t[1]^=t[2],t[0]^=t[3],t[2]^=e,e=t[3],t[3]=(e<<11|e>>>21)>>>0,r}}class a extends n{constructor(t=s){super(),this.buffer=new Uint32Array(4),this.seed(t)}copy(){return new a(this.buffer)}bytes(){return new Uint8Array(this.buffer.buffer)}seed(t){return this.buffer.set(t),this}int(){const t=this.buffer;let e,r=t[3];return r^=r<<11,r^=r>>>8,t[3]=t[2],t[2]=t[1],e=t[1]=t[0],t[0]=(r^e^e>>>19)>>>0}}class d extends n{constructor(t=i){super(),this.buffer=new Uint32Array(5),this.seed(t)}copy(){return new d(this.buffer)}seed(t){return this.buffer.set(t),this}bytes(){return new Uint8Array(this.buffer.buffer)}int(){const t=this.buffer;let e,r=t[3];return r^=r>>>2,r^=r<<1,t[3]=t[2],t[2]=t[1],e=t[1]=t[0],r^=e,r^=e<<4,t[0]=r,r+(t[4]+=362437)>>>0}}class b extends n{constructor(t=3737844653){super(),this.buffer=new Uint32Array(4),this.seed(t)}bytes(){return new Uint8Array(this.buffer.buffer)}copy(){const t=new b;return t.buffer.set(this.buffer),t}seed(t){const e=this.buffer;e.set([t,0,0,0]);for(let t=0,r=1;r<8;t=r++){let n=(e[3&t]^e[3&t]>>>30)>>>0;n=35173*n+((27655*n&65535)<<16)>>>0,e[3&r]^=r+n>>>0}return this}int(){const t=this.buffer;let e=t[0];return e^=e<<15,e^=e>>>18,e^=t[3]<<11,t[0]=t[1],t[1]=t[2],t[2]=t[3],t[3]=e,e+t[2]>>>0}}const l=e.hasCrypto()?t=>window.crypto.getRandomValues(t):t=>{const e=t.length;for(let r=0;r<e;r++)t[r]=255&h.int();return t};t.ARandom=n,t.SYSTEM=h,t.Smush32=f,t.SystemRandom=o,t.XorShift128=a,t.XorWow=d,t.Xoshiro128=c,t.XsAdd=b,t.randomBytes=l,t.randomID=(t=4,e="",r="abcdefghijklmnopqrstuvwxyz",n=h)=>{for(const s=r.length;--t>=0;)e+=r[0|n.float(s)];return e},t.uuidv4Bytes=t=>((t=l(t||new Uint8Array(16)))[6]=64|15&t[6],t[8]=128|63&t[8],t),t.weightedRandom=(t,e,n=h)=>{const s=t.length;r.assert(s>0,"no choices given");const i=t.map(e?(t,r)=>[t,e[r]]:t=>[t,1]).sort((t,e)=>e[1]-t[1]),f=i.reduce((t,e)=>t+e[1],0);return r.assert(f>0,"no choices given"),()=>{const t=n.float(f);let e=f;for(let r=0;r<s;r++)if(e-=i[r][1],e<=t)return i[r][0]}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/checks"),require("@thi.ng/api")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/checks","@thi.ng/api"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.random={}),t.thi.ng.checks,t.thi.ng.api)}(this,(function(t,e,r){"use strict";class n{float(t=1){return 2.3283064370807974e-10*this.int()*t}norm(t=1){return 2*(2.3283064370807974e-10*this.int()-.5)*t}minmax(t,e){return this.float()*(e-t)+t}gaussian(t=10,e=-.5,r=1){let n=0,s=t;for(;s-- >0;)n+=this.float(r);return n/t+e}}const s=[3737844653,799659867,3827263459,1552149530],i=[...s,4137311345];class f extends n{constructor(t=3737844653){super(),this.buffer=new Uint32Array([t,0])}copy(){const t=new f;return t.buffer.set(this.buffer),t}seed(t){return this.buffer.set([t,0]),this}int(){const t=this.buffer,e=1540483477,r=t[1]++*e>>>0,n=t[0]=(r^r>>24^t[0]*e>>>0)*e>>>0;return(n^n>>>13)>>>0}}const u=Math.random;class o extends n{int(){return 4294967295*u()>>>0}float(t=1){return u()*t}norm(t=1){return 2*(u()-.5)*t}}const h=new o;class c extends n{constructor(t=s){super(),this.buffer=new Uint32Array(4),this.seed(t)}copy(){return new c(this.buffer)}bytes(){return new Uint8Array(this.buffer.buffer)}seed(t){return this.buffer.set(t),this}int(){const t=this.buffer;let e=t[0]+t[3];const r=(e<<7|e>>>25)>>>0;return e=t[1]<<9,t[2]^=t[0],t[3]^=t[1],t[1]^=t[2],t[0]^=t[3],t[2]^=e,e=t[3],t[3]=(e<<11|e>>>21)>>>0,r}}class a extends n{constructor(t=s){super(),this.buffer=new Uint32Array(4),this.seed(t)}copy(){return new a(this.buffer)}bytes(){return new Uint8Array(this.buffer.buffer)}seed(t){return this.buffer.set(t),this}int(){const t=this.buffer;let e,r=t[3];return r^=r<<11,r^=r>>>8,t[3]=t[2],t[2]=t[1],e=t[1]=t[0],t[0]=(r^e^e>>>19)>>>0}}class d extends n{constructor(t=i){super(),this.buffer=new Uint32Array(5),this.seed(t)}copy(){return new d(this.buffer)}seed(t){return this.buffer.set(t),this}bytes(){return new Uint8Array(this.buffer.buffer)}int(){const t=this.buffer;let e,r=t[3];return r^=r>>>2,r^=r<<1,t[3]=t[2],t[2]=t[1],e=t[1]=t[0],r^=e,r^=e<<4,t[0]=r,r+(t[4]+=362437)>>>0}}class b extends n{constructor(t=3737844653){super(),this.buffer=new Uint32Array(4),this.seed(t)}bytes(){return new Uint8Array(this.buffer.buffer)}copy(){const t=new b;return t.buffer.set(this.buffer),t}seed(t){const e=this.buffer;e.set([t,0,0,0]);for(let t=0,r=1;r<8;t=r++){let n=(e[3&t]^e[3&t]>>>30)>>>0;n=35173*n+((27655*n&65535)<<16)>>>0,e[3&r]^=r+n>>>0}return this}int(){const t=this.buffer;let e=t[0];return e^=e<<15,e^=e>>>18,e^=t[3]<<11,t[0]=t[1],t[1]=t[2],t[2]=t[3],t[3]=e,e+t[2]>>>0}}const l=e.hasCrypto()?t=>window.crypto.getRandomValues(t):t=>{const e=t.length;for(let r=0;r<e;r++)t[r]=255&h.int();return t};t.ARandom=n,t.SYSTEM=h,t.Smush32=f,t.SystemRandom=o,t.XorShift128=a,t.XorWow=d,t.Xoshiro128=c,t.XsAdd=b,t.randomBytes=l,t.randomID=(t=4,e="",r="abcdefghijklmnopqrstuvwxyz",n=h)=>{for(const s=r.length;--t>=0;)e+=r[0|n.float(s)];return e},t.uuidv4Bytes=t=>((t=l(t||new Uint8Array(16)))[6]=64|15&t[6],t[8]=128|63&t[8],t),t.weightedRandom=(t,e,n=h)=>{const s=t.length;r.assert(s>0,"no choices given");const i=t.map(e?(t,r)=>[t,e[r]]:t=>[t,1]).sort((t,e)=>e[1]-t[1]),f=i.reduce((t,e)=>t+e[1],0);return r.assert(f>0,"no choices given"),()=>{const t=n.float(f);let e=f;for(let r=0;r<s;r++)if(e-=i[r][1],e<=t)return i[r][0]}},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/random", | ||
"version": "1.4.15", | ||
"version": "1.4.16", | ||
"description": "Pseudo-random number generators w/ unified API", | ||
@@ -45,11 +45,11 @@ "module": "./index.js", | ||
"@types/node": "^14.0.26", | ||
"mocha": "^8.0.1", | ||
"mocha": "^8.1.1", | ||
"nyc": "^15.1.0", | ||
"ts-node": "^8.10.1", | ||
"typedoc": "^0.17.6", | ||
"typedoc": "^0.18.0", | ||
"typescript": "^3.9.7" | ||
}, | ||
"dependencies": { | ||
"@thi.ng/api": "^6.12.0", | ||
"@thi.ng/checks": "^2.7.4" | ||
"@thi.ng/api": "^6.12.1", | ||
"@thi.ng/checks": "^2.7.5" | ||
}, | ||
@@ -72,3 +72,3 @@ "files": [ | ||
"sideEffects": false, | ||
"gitHead": "6a1b929361ede67d425a0dbd12cf4bce56c1f8f8" | ||
"gitHead": "81ba08f0ce3a0ece6901944e7b5827283d13a9e6" | ||
} |
64853
Updated@thi.ng/api@^6.12.1
Updated@thi.ng/checks@^2.7.5