moleculer
moleculer copied to clipboard
[lodash] Remove usage of _.random
See #433 for context.
Describe the solution you'd like
Remove usage of _.random
throughout Moleculer.
Describe alternatives you've considered Vanilla suggestion would be something like Source: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_random
//Native ES6
const random = (a = 1, b = 0) => {
const lower = Math.min(a, b);
const upper = Math.max(a, b);
return lower + Math.random() * (upper - lower);
};
const randomInt = (a = 1, b = 0) => {
const lower = Math.ceil(Math.min(a, b));
const upper = Math.floor(Math.max(a, b));
return Math.floor(lower + Math.random() * (upper - lower + 1))
};
Additional context https://github.com/moleculerjs/moleculer/search?q=.random&unscoped_q=.random