Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was using faker in our codebase at work to generate some random data. I wanted to pick one of a few status codes. I was surprised to see that faker.random was deprecated and the random sample was moved into different datatypes. But the array datatype was deprecated so now there is no random sample from array in faker, seemingly. They say "Use your own function to build complex arrays." Isn't that what faker is all about?

Maybe there is good reason for this. I'm not real familiar with this space. It's not so hard to implement something yourself. But I suspect the description of "missing js randomness library" may have some merit.



I'm one of the maintainers of Faker, so hopefully I can help remedy any situation we inadvertently created.

https://fakerjs.dev/api/helpers.html#arrayelement

I believe is what you're looking for. The issue, as I recall, is that all of Faker is random, so what does it mean to have a `random` module namespace. We moved it out of a hope for improved clarity.


Oh shit, youre right. Thanks for that. I think I saw that method but didnt realize it is implicitly random (like an idiot)




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: