Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lffg-labs/faker-create-factory
Factory creator utility to Faker.js
https://github.com/lffg-labs/faker-create-factory
Last synced: 12 days ago
JSON representation
Factory creator utility to Faker.js
- Host: GitHub
- URL: https://github.com/lffg-labs/faker-create-factory
- Owner: lffg-labs
- License: mit
- Created: 2019-08-30T16:55:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T08:33:15.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T23:11:18.598Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/faker-create-factory
- Size: 839 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `faker-create-factory`
🏭 Factory creator utility to Faker.js
[![Build Status](https://circleci.com/gh/lffg/faker-create-factory.svg?style=svg)](https://circleci.com/gh/lffg/faker-create-factory)
[![NPM](https://img.shields.io/npm/v/faker-create-factory.svg?logo=npm)](https://npmjs.org/package/faker-create-factory)
![Uses TypeScript](https://img.shields.io/badge/Uses-Typescript-294E80.svg)## Installing
```shell
yarn add faker faker-create-factory# If you're using NPM:
# npm install 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.
## Authors and License
[lffg](https://github.com/lffg) and [contributors](https://github.com/lffg/faker-create-factory/graphs/contributors).
MIT License, see the included [MIT](https://github.com/lffg/faker-create-factory/blob/master/LICENSE) file.