Factory creator utility to Faker.js
npm install faker-create-factoryfaker-create-factory🏭 Factory creator utility to Faker.js


!Uses TypeScript
``shell
yarn add faker faker-create-factory
Basic Usage
`typescript
import { createFactory } from 'faker-create-factory';export const UserFactory = createFactory((faker) => ({
id: faker.random.uuid(),
email: faker.internet.email(),
username: faker.internet.userName(),
password: '123'
}));
// And the use it as:
UserFactory.generate(); // User
UserFactory.generateMany(5); // Array
`If needed, you can override the default schema:
`typescript
import { createFactory } from 'faker-create-factory';export const Factory = createFactory((faker) => ({
// ...
}));
// Plain object:
Factory.generate({
// ...
});
// With a faker instance:
Factory.generateMany(5, (faker) => {
// ...
});
`The two options (_plain object_ and _with a faker instance_) described above are available in both
generate and generateMany` methods.lffg and contributors.
MIT License, see the included MIT file.