moleculer icon indicating copy to clipboard operation
moleculer copied to clipboard

[lodash] Remove usage of _.random

Open abdavid opened this issue 4 years ago • 0 comments

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

abdavid avatar May 22 '20 19:05 abdavid