New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

minifaker

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minifaker

lightweight faker.js

  • 1.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
increased by12.43%
Maintainers
1
Weekly downloads
 
Created
Source

minifaker

Generate fake data.
An alternative to faker.js but with cjs or esm syntax

NPM

npm i minifaker

Why

faker.js is too big and there is no tree shaking. https://github.com/Marak/faker.js/issues/785

Why not create a pull request to faker.js?

Too much work to get the pull request denied. Instead, I will be adding new functions here from time to time.

Better alternatives

I will deprecate functions with better alternatives. use npm i nanoid to generate string ID use npm i lorem-ipsum to generate lorem words

Duplicates

I've notice that faker locales have duplicate words :S.
I will remove the duplicates when importing locale files to reduce size as much as possible.

Example / usage

Using functions

// You can either import minifaker completely or import the functions you need
import minifaker, { arrayElement } from 'minifaker'
// const minifaker = require('minifaker')

minifaker.number()
arrayElement(['one', 'two', 'three'])

Using locale dependent functions

import minifaker, { cityName } from 'minifaker'
import 'minifaker/dist/locales/en' // first import is set a default locale
import 'minifaker/dist/locales/fr'

minifaker.firstName({ gender: 'female' }) // female name in english
cityName({ locale: 'fr' }) // french city name

Function mapping

FunctionLocalesFaker.js
arrayElementn/aarrayElement
numbern/anumber,float
booleann/aboolean
use nanoidn/auuid
firstNameen,frfirstName
phoneNumberen,fr,fr_CAphoneNumber
cityNameen,frcityName
cityPrefixencityPrefix
citySufixencitySufix
imageUrlFromPlaceIMGn/aimageUrl
imageUrlFromPlaceholdern/aimageUrl
use lorem-ipsum.jsn/alorem
objectElementn/aobjectElement
arrayn/an/a

FAQs

Package last updated on 13 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc