Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lodash] Remove usage of _.random #749

Closed
abdavid opened this issue May 22, 2020 · 0 comments
Closed

[lodash] Remove usage of _.random #749

abdavid opened this issue May 22, 2020 · 0 comments

Comments

@abdavid
Copy link

abdavid commented May 22, 2020

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

@MrDroid1 MrDroid1 mentioned this issue May 12, 2023
9 tasks
@icebob icebob closed this as completed May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants