faker icon indicating copy to clipboard operation
faker copied to clipboard

Use wrapped functions instead of classes for modules

Open Shinigami92 opened this issue 3 years ago • 2 comments

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

Shinigami92 avatar Aug 09 '22 21:08 Shinigami92

Team Decision

We will think about this again when we actually start the tree shaking.

ST-DDT avatar Mar 16 '23 17:03 ST-DDT

I wrote a proposal for a design for this one in #2667 (because it is quite long)

  • #2667

ST-DDT avatar Feb 15 '24 00:02 ST-DDT

Superseded by #2667

  • #2667

ST-DDT avatar Feb 29 '24 18:02 ST-DDT