60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var RNG = function () {
|
|
function RNG() {
|
|
_classCallCheck(this, RNG);
|
|
}
|
|
|
|
_createClass(RNG, [{
|
|
key: 'next',
|
|
value: function next() {
|
|
throw new Error('RNG.next must be overridden');
|
|
}
|
|
}, {
|
|
key: 'seed',
|
|
value: function seed(_seed, opts) {
|
|
throw new Error('RNG.seed must be overridden');
|
|
}
|
|
}, {
|
|
key: 'clone',
|
|
value: function clone(seed, opts) {
|
|
throw new Error('RNG.clone must be overridden');
|
|
}
|
|
}, {
|
|
key: '_seed',
|
|
value: function _seed(seed, opts) {
|
|
// TODO: add entropy and stuff
|
|
|
|
if (seed === (seed | 0)) {
|
|
return seed;
|
|
} else {
|
|
var strSeed = '' + seed;
|
|
var s = 0;
|
|
|
|
for (var k = 0; k < strSeed.length; ++k) {
|
|
s ^= strSeed.charCodeAt(k) | 0;
|
|
}
|
|
|
|
return s;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'name',
|
|
get: function get() {
|
|
throw new Error('RNG.name must be overridden');
|
|
}
|
|
}]);
|
|
|
|
return RNG;
|
|
}();
|
|
|
|
exports.default = RNG;
|
|
//# sourceMappingURL=rng.js.map
|