@lazy-random/generators-seedrandom
Version:
69 lines (67 loc) • 2.38 kB
JavaScript
!function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? t(exports, require("@lazy-random/generators-function"), require("seedrandom"), require("@lazy-random/clone-class")) : "function" == typeof define && define.amd ? define([ "exports", "@lazy-random/generators-function", "seedrandom", "@lazy-random/clone-class" ], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).LazyRandomGeneratorsSeedrandom = {}, e.generatorsFunction, e.seedrandom, e.cloneClass);
}(this, (function(e, t, s, n) {
"use strict";
const o = Object.freeze({
entropy: !0
});
class RNGSeedRandom extends t.RNGFunction {
_seedable=!0;
constructor(e, t, ...s) {
super(e, t, ...s);
}
static createLib(...e) {
return new this(e[1], e[2], e[0], ...e.slice(3));
}
static create(...e) {
return new this(...e);
}
_init_check(e, t, ...s) {}
_init(e, t, ...s) {
this._opts = this._opts || Object.assign({}, o), this._seedrandom = this.__generator(...s),
super._init(e, t, ...s);
}
_NAME="seedrandom";
_TYPE=null;
get name() {
return `${this._NAME}${this._TYPE ? ":" + this._TYPE : ""}`;
}
__generator(e) {
if (e && "string" == typeof e) switch (this._TYPE = null, e) {
case "alea":
case "tychei":
case "xor128":
case "xor4096":
case "xorshift7":
case "xorwow":
this._TYPE = e = s[e];
break;
default:
if (!e.includes("..") && /^[a-z\-\.]+$/i.test(e)) {
this._TYPE = e, e = require(`seedrandom/lib/${e}`);
break;
}
throw new RangeError(`unknow seedrandom lib name: ${e}`);
} else this._TYPE = e ? e.name : null;
return e || s;
}
get options() {
return this._opts;
}
get state() {
const e = this._rng.state;
if ("function" == typeof e) return e();
}
seed(e, t, ...s) {
this._opts = null === t ? void 0 : t || this._opts, this._rng = this._seedrandom(this._seedAuto(e), this._opts, ...s);
}
clone(e, t, ...s) {
return n.cloneClass(RNGSeedRandom, this, e, t, ...s);
}
}
e.RNGSeedRandom = RNGSeedRandom, e.default = RNGSeedRandom, e.defaultOptions = o,
Object.defineProperty(e, "__esModule", {
value: !0
});
}));
//# sourceMappingURL=index.umd.production.min.cjs.map