faker
faker copied to clipboard
Use wrapped functions instead of classes for modules
Clear and concise description of the problem
Currently we need to bind this in the constructor of each module to support stuff like
const color = faker.color
color.rgb()
// and
const rgb = faker.color.rgb
rgb()
Suggested solution
Instead of using js classes we could instead use wrapped functions like e.g. composables are working in Vue / VueUse
Alternative
No response
Additional context
This might be a breaking change as with that you would not create a new class via new Faker(...) anymore
Also we need to benchmark if there would be performance regressions or benefits :thinking:
I would like to setup a PR if this proposal gets accepted by the team
Team Decision
We will think about this again when we actually start the tree shaking.
I wrote a proposal for a design for this one in #2667 (because it is quite long)
- #2667
Superseded by #2667
- #2667