Closed AustinGil closed 2 years ago
FFR: This was added in https://github.com/faker-js/faker/commit/7ad22c2e2aae2f5e6215bcdb91cf3fd28e727d92 v5.5.0
The actual issue is lost to time.
Currently the helper, random and datatype modules are kind of ambiguous. So I consider removing datatype to be a viable solution, not sure what the other maintainers think though.
I found the original content in this event history: Marak/faker.js - Github Event History
Unfortunately, it does not contain a specific reason for that change.
We created a discussion on how to improve on this: https://github.com/faker-js/faker/discussions/805
When we bring stuff from datatype back to random, I think we should use new names like:
datatype.number
=> random.int
(or random.nextInt
? This would align with some other languages like Java :thinking:)datatype.float
=> random.number
I think moving it to individual modules (strings/numbers) might provide a better developer experience, because first you select what you want and then you have all the variations available for use.
I think moving it to individual modules (strings/numbers) might provide a better developer experience, because first you select what you want and then you have all the variations available for use.
Where would you put boolean
, hex
, datetime
and uuid
?
I think functions like array
and json
can be removed because I don't know which use-case they fulfill :shrug:
array( numOrRange, elemSource())
, ...I can see the discussion going on here and in #805 - this is a bit confusing. Maybe we should close this issue and focus on the discussion only, which should then be spit into smaller issues?
In an older version, many of the methods on
faker.random
that return primitive values were deprecated and moved tofaker.datatype
. I never understood the reason, and I'd argue that restoring them is better developer experience.faker.random
random
is better for intellisense becausefaker.datatype
clashes withfaker.database
. It's much nicer to just type "faker.r" then tab.faker.random
andfaker.datatype
serve the same purpose of grabbing fake primitives.I'm bringing some of my own bias and assumptions here, so I reserve the right to be totally wrong, but I thought I would mention it in the spirit of trying to make this library better.