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.8.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 https://github.com/Marak/faker.js

NPM

npm i minifaker

Why

faker.js is too big and it's not currently supporting tree shaking. https://github.com/Marak/faker.js/issues/785

Why not create a pull request to faker.js?

Supporting ES6 modules for faker.js would need a big restructure change.

Right now, I just need a couple of functions and it's faster to create a new package mirroring functions without having to do a lot of refactoring. However, importing the entire package will take work and time, but at least I can start using it without having to finish it.

I also want to use Typescript and introduce new functions.

Better function 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'll try fix 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, Gender } from 'minifaker'
import 'minifaker/dist/locales/en' // first import is set a default locale
import 'minifaker/dist/locales/fr'

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

Function mapping

Faker.jsLocalesFunc
arrayElementn/aarrayElement
number,floatn/anumber
booleann/aboolean
uuidn/ause nanoid
firstNameen,frfirstName
phoneNumberen,fr,fr_CAphoneNumber
cityNameen,frcityName
cityPrefixencityPrefix
citySufixencitySufix
imageUrln/aimageUrlFromPlaceIMG
imageUrln/aimageUrlFromPlaceholder
loremn/ause lorem-ipsum
objectElementn/aobjectElement
n/an/aarray
lastNameen,frlastName
jobTitleenjobTitle
jobAreaenjobArea
jobDescriptorenjobDescriptor
jobTypeen,frjobType

FAQs

Package last updated on 14 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