https://github.com/willybrauner/fake
🅧 Fake data generator
https://github.com/willybrauner/fake
fake-data lib library typescript
Last synced: 2 months ago
JSON representation
🅧 Fake data generator
- Host: GitHub
- URL: https://github.com/willybrauner/fake
- Owner: willybrauner
- Created: 2021-08-18T10:30:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-18T16:07:36.000Z (almost 4 years ago)
- Last Synced: 2025-03-24T16:47:31.250Z (3 months ago)
- Topics: fake-data, lib, library, typescript
- Language: TypeScript
- Homepage:
- Size: 316 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @wbe/fake
Generate fake data image/text/video allowing to test UI components




## Installation
```shell script
$ npm install -s @wbe/fake
```## How to use
Import `Fake`:
```tsx
import Fake from "@wbe/fake";
```## API
- [responsiveImageData](#responsiveImageData)
- [videoUrl](#videoUrl)
- [videoId](#videoId)
- [title](#title)
- [text](#text)Get an array of random IFakeImage objects.
```tsx
responsiveImageData(pRatio, pBreakpoints);
```#### Parameters
- `pRatio (number)`: Image ratio - default: `4 / 3`
- `pBreakpoints (number[])`: Breakpoints list - default: `[640, 1024, 1440, 1920]`#### Returns
`(Array) IFakeImage[]`: Array of IFakeImage data object
#### Example
```tsx
// will returned an array of IFakeImage object with 16/9 ratio
const responsiveImageData = Fake.responsiveImageData(16 / 9);
```Get a random video URL.
```tsx
videoUrl(pFakeVideoType, pYoutubeId, pVimeoId);
```#### Parameters
- `pFakeVideoType (EVideoType)`: Type of video
- `pYoutubeId (string)`: Specify youtube ID to use - default: random ID
- `pVimeoId (string)`: Specify vimeo ID to use - default: random ID#### Returns
`(string)`: video URL
#### Example
```tsx
// will returned a random youtube url
const youtubeUrl = Fake.videoUrl(EVideoType.YOUTUBE);
```Get a random video ID.
```tsx
videoId(pFakeVideoType);
```#### Parameters
- `pFakeVideoType (EVideoType)`: Type of video
#### Returns
`(string)`: video ID
#### Example
```tsx
// will returned a random vimeo id
const vimeoUrl = Fake.videoId(EVideoType.VIMEO);
```Get a random title.
```tsx
title(pWords);
```#### Parameters
- `pWords (number)`: Number of words - default: `1`
#### Returns
`(string)`: title
#### Example
```tsx
// will returned two random words
const title = Fake.title(2);
```Get random text.
```tsx
text(pSentencies);
```#### Parameters
- `pSentencies (number)`: Number of sentencies - default: `1`
#### Returns
`(string)`: text
#### Example
```tsx
// will returned four random sentencies
const text = Fake.text(4);
```