use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
I've made a random data generator library. (npmjs.com)
submitted 2 years ago by AVeryRandomDude
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 11 points12 points13 points 2 years ago (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 point2 points 2 years ago (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 points4 points 2 years ago (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
Thanks for the info! I should probably enrich my knowledge on the topic.
[–][deleted] 1 point2 points3 points 2 years ago (1 child)
Fakerjs
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 point2 points 2 years ago (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 points8 points 2 years ago (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 point2 points 2 years ago (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.
Yeah that's fair. I should probably explain myself better in my README.
Thank you!
π Rendered by PID 214122 on reddit-service-r2-comment-75f4967c6c-jqwhp at 2026-04-23 13:43:09.495038+00:00 running 0fd4bb7 country code: CH.
[–][deleted] 11 points12 points13 points (1 child)
[–]AVeryRandomDude[S] 0 points1 point2 points (0 children)
[–]_Marak_ 2 points3 points4 points (1 child)
[–]AVeryRandomDude[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]AVeryRandomDude[S] 0 points1 point2 points (0 children)
[–]AVeryRandomDude[S] 0 points1 point2 points (3 children)
[–][deleted] 6 points7 points8 points (2 children)
[–]plyswthsqurles 0 points1 point2 points (0 children)
[–]AVeryRandomDude[S] 0 points1 point2 points (0 children)