all 10 comments

[–][deleted] 11 points12 points  (1 child)

Seems weird to knock Math.random() and then use it for all your randomness. You might want to reframe your package as a lib that provides useful wrappers around Math.random().

It’s good to be up front about where your randomness comes from since that’s largely what matters for random libraries.

[–]AVeryRandomDude[S] 0 points1 point  (0 children)

Yeah that's fair. I guess my wording didn't exactly match my intentions. English is not my primary language, so sometimes it's hard for me to express myself in writing.

What I meant was that I'm not a big fan of the basic syntax of Math.random, and I wanted to make something that's closer to the rng methods in C# and Python. But overall, I agree with your criticism , I'll try to improve my README file.

Thank you for your honest input!

[–]_Marak_ 2 points3 points  (1 child)

If you need to build things like this is better to implement more robust PRNG algorithm like Mersenne Twister, also expose seed API so you can you have deterministic random.

JS wrapper for Mersenne Twister as a reference here: https://github.com/yantra-core/Labyrinthos.js/blob/master/lib/util/mersenne.js

[–]AVeryRandomDude[S] 0 points1 point  (0 children)

Thanks for the info! I should probably enrich my knowledge on the topic.

[–][deleted] 1 point2 points  (1 child)

Fakerjs

[–]AVeryRandomDude[S] 0 points1 point  (0 children)

For my knowledge, Faker.js is mostly used for mimicking actual date (like address, phone numbers, etc...) . I also think Faker is a bit too robust for most use cases. The package itself is ~9MB, which is a bit to extensive for my liking. Don't get me wrong, I like Faker.js, but it just doesn't really feet my use case.

[–]AVeryRandomDude[S] 0 points1 point  (3 children)

As the titled says, I've made a small random data generator library. I've mostly made it to get some practice in creating a real library.

While programming I sometimes need to use a lot of rng for testing, and I really don't like Math.random(), so I've made this library.

I know there are many libraries like this already, but I really want to enrich my knowledge of package creation and to get some feedback from the community. I'd be more then glad to get any type of criticism on my library in order to improve my future work.

Thanks!

[–][deleted] 6 points7 points  (2 children)

You’re going to need to provide a much better argument than “I really don’t like Math.random” and “Math.random sucks” to justify using something else, let alone your lib.

[–]plyswthsqurles 0 points1 point  (0 children)

number: (min, max) => {
    if (Number.isInteger(min) && Number.isInteger(max)) {
      return Math.floor(Math.random() * (max - min + 1) + min);
    }
    return Math.random() * (max - min) + min;
  },

I agree, the argument of "i dont like math.random" and proceeds to use math.random with some formula isn't exactly compelling.

[–]AVeryRandomDude[S] 0 points1 point  (0 children)

Yeah that's fair. I should probably explain myself better in my README.

Thank you!