Skip to content

BolajiOlajide/ng-faker

Repository files navigation

NG-Faker

npm Open Source Love Open Source Love

Usage

Installation

Install with npm:

npm install ng-faker --save-dev

Install with yarn:

yarn add ng-faker --dev

Browser

For now, we don't have support for the browser directly. We're working on that and should have that up really soon.

Node.js

var ngfaker = require('ng-faker');

var randomName = ngfaker.name.firstName(); // Annabelle
var randomWord = ngfaker.lorem.phrase(); // Thanks so much.

API

ngfaker.fake()

ngfaker contains a super useful generator method ngfaker.fake for combining ngfaker API methods using a mustache string format.

Example

console.log(
  ngfaker.fake('{{name.prefix}}, {{name.firstName}} {{name.lastName}}'),
);
// outputs: "Dr. Annabelle Smith"

This will interpolate the format string with the value of methods name.prefix(), name.lastName() and name.firstName().

API Methods

  • account
    • bank
    • accountNumber
  • address
    • state
    • states
    • localGovernment
    • localGovernments
  • lorem
    • word
    • phrase
  • name
    • firstName
    • lastName
    • prefix
    • fullName
  • phone
    • phoneNumber
    • serviceProvider
  • fake
  • random
    • boolean
    • number
    • arrayElement
    • objectElement
    • alphanumeric
    • hexadecimal

Localization

The default language locale is set to English.

Setting a new locale is simple:

var ngfaker = require('ng-faker');
// sets locale to yo (Yoruba)
ngfaker.setLocale('yo');
// or
ngfaker.locale = 'yo';
  • yo - Yoruba
  • en - English
  • ha - hausa
  • ig - igbo
  • ek - Efik
  • bn - Benin
  • ur - urhobo

Other locales will be added soon...

Custom Locale

Adding a new locale is equally easy:

ngFaker.addLocale('ef', {
  title: 'Efik',
  name: ['Efik1', 'Efik2'],
  lorem: [],
  address: [],
});

Tests

    npm run test

Version Release Schedule

If you require the absolute latest version of ng-faker the master branch on the official repo should always be up to date and working.

Maintainers

  • Bolaji Olajide
  • Rotimi Babalola
  • Oyindamola Subair

Contributors


Rotimi Babalola

Bolaji Olajide

Subair Oyindamola

Olamilekan Odukoya

Ayomiga

JCobhams
:---: :---: :---:

Seun Faluyi

Neiva07

nero-adaware
:---: :---: :---:

|
sudo-kaizen

ng-faker was inspired by and has used data definitions and logic from: