New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

random-extra

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-extra - npm Package Compare versions

Comparing version
4.0.5
to
4.0.6
+16
src/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./random"), exports);
const random_1 = require("./random");
exports.default = random_1.random;
//# sourceMappingURL=index.js.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var Random_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.random = exports.Random = void 0;
/// <reference types="node" />
const expect_1 = require("@lazy-random/expect");
const rng_abstract_1 = require("@lazy-random/rng-abstract");
const rng_factory_1 = require("@lazy-random/rng-factory");
const core_decorators_1 = require("core-decorators");
const clone_class_1 = require("@lazy-random/clone-class");
const random_core_1 = require("@lazy-random/random-core");
/**
* Seedable random number generator supporting many common distributions.
*
* Defaults to Math.random as its underlying pseudorandom number generator.
*
* @name Random
* @class
*
* @param {Rng|function} [rng=Math.random] - Underlying pseudorandom number generator.
*/
let Random = Random_1 = class Random extends random_core_1.RandomCore {
_init(rng) {
if (rng) {
//ow(rng, ow.object.instanceOf(RNG))
(0, expect_1.expect)(rng).instanceof(rng_abstract_1.RNG);
}
Object.defineProperty(this, 'Random', {
configurable: false,
enumerable: false,
get() {
return Random_1;
},
});
this.use(rng);
}
/**
* Creates a new `Random` instance, optionally specifying parameters to
* set a new seed.
*
* @see Rng.clone
*
* @param {string} [seed] - Optional seed for new RNG.
* @param {object} [opts] - Optional config for new RNG options.
* @return {Random}
*/
clone(seed, ...args) {
let o;
if (this instanceof Random_1) {
// @ts-ignore
o = (this.__proto__.constructor);
}
else {
o = Random_1;
}
// @ts-ignore
return new o(this.rng.clone(seed, ...args));
}
/**
* Sets the underlying pseudorandom number generator used via
* either an instance of `seedrandom`, a custom instance of RNG
* (for PRNG plugins), or a string specifying the PRNG to use
* along with an optional `seed` and `opts` to initialize the
* RNG.
*
* @example
* const random = require('random')
*
* random.use('xor128', 'foobar')
* // or
* random.use(seedrandom('kittens'))
* // or
* random.use(Math.random)
*
* @param {...*} args
*/
use(arg0, ...args) {
this._rng = (0, rng_factory_1.RNGFactory)(arg0, ...args);
return this;
}
/**
* create new Random and use
*/
newUse(arg0, ...args) {
let o = (0, clone_class_1.getClass)(Random_1, this);
return new o((0, rng_factory_1.RNGFactory)(arg0, ...args));
}
cloneUse(arg0, ...args) {
let o = this.clone();
o.use(arg0, ...args);
return o;
}
};
Random.Random = Random_1;
Random = Random_1 = __decorate([
core_decorators_1.autobind
], Random);
exports.Random = Random;
exports.random = new Random();
// @ts-ignore
//random.default = random
Object.defineProperty(exports.random, 'default', {
configurable: false,
enumerable: false,
get() {
return exports.random;
},
});
Object.defineProperty(Random, 'default', {
configurable: false,
enumerable: false,
get() {
return exports.random;
},
});
Object.defineProperty(exports.random, "__esModule", { value: true });
// defaults to Math.random as its RNG
exports.default = exports.random;
//# sourceMappingURL=random.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.array_unique_unsafe = void 0;
/**
* for non-strict check, try get a little
*/
function array_unique_unsafe(arr) {
return arr.filter((v, i, arr) => arr.indexOf(v) === i);
}
exports.array_unique_unsafe = array_unique_unsafe;
//# sourceMappingURL=util.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.get_range_by_size_sum = exports.fixZero = void 0;
const num_is_zero_1 = require("num-is-zero");
Object.defineProperty(exports, "fixZero", { enumerable: true, get: function () { return num_is_zero_1.fixZero; } });
const sum_1 = require("@lazy-num/sum");
function get_range_by_size_sum(size, sum) {
sum = sum || (0, sum_1.sum_1_to_n)(size);
let score = sum;
let resultArray = [];
let randomTotal = 0;
let i;
for (i = 0; i < size - 1; i++) {
let res = Math.round(score / size);
let random = res;
resultArray[i] = random;
randomTotal += resultArray[i];
score = score - random;
}
let result = sum - randomTotal;
resultArray[i] = result;
resultArray.sort((a, b) => a - b);
resultArray.push(score);
if (sum < 0) {
resultArray.push(sum - resultArray[0]);
}
resultArray.push(sum - resultArray[resultArray.length - 1]);
resultArray.push(score < 0 ? sum + size : sum - size);
for (i = 0; i < size; i++) {
resultArray.push(score < 0 ? 0 - i : i);
}
resultArray.push((score < 0 ? sum + size - 1 : sum - size + 1));
resultArray.sort((a, b) => a - b);
let min = resultArray[0];
let max = resultArray[resultArray.length - 1];
return {
min,
max,
sum,
resultArray,
};
}
exports.get_range_by_size_sum = get_range_by_size_sum;
//# sourceMappingURL=math.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryRequire = void 0;
function tryRequire(name) {
return require(name);
}
exports.tryRequire = tryRequire;
//# sourceMappingURL=req.js.map
+10
-0

@@ -6,2 +6,12 @@ # Change Log

## [4.0.6](https://github.com/bluelovers/ws-random/compare/random-extra@4.0.5...random-extra@4.0.6) (2022-10-29)
### 🐛 Bug Fixes
* lost .js ([cecfa2e](https://github.com/bluelovers/ws-random/commit/cecfa2e94a1ca69891afe7f13e8774700b921dd5))
## [4.0.5](https://github.com/bluelovers/ws-random/compare/random-extra@4.0.4...random-extra@4.0.5) (2022-10-29)

@@ -8,0 +18,0 @@

+2
-2
{
"name": "random-extra",
"version": "4.0.5",
"version": "4.0.6",
"description": "Seedable random number generator supporting many common distributions.",

@@ -120,3 +120,3 @@ "keywords": [

"packageManager": "yarn@^1.22.11",
"gitHead": "bd032b505ff8eaab9dba9143b38c11f877619790"
"gitHead": "4671b3a00a3040bbc4a967c78a4e56820c3571f1"
}