Skip to content

Use wrapped functions instead of classes for modules #1250

@Shinigami92

Description

@Shinigami92

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 🤔

I would like to setup a PR if this proposal gets accepted by the team

Metadata

Metadata

Assignees

Labels

breaking changeCannot be merged when next version is not a major releasec: refactorPR that affects the runtime behavior, but doesn't add new features or fixes bugs

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions