1.0.1 • Published 4 years ago

fake-things v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Fake Things

fake-things is a lightweight data generator built in JavaScript and intended for designers and developers as an alternative to solutions already in existence. It's straight-forward approach was made for compatibility and versatility.

Explore 1000's of unique strings and objects.

If you would like to contribute please submit a pull request

Setup

npm i fake-things

Methods at a glace

var Fake = require("fake-things");

Fake.Email(); //"kassadef@gmail.com"
Fake.FirstName(); //"Violeta"
Fake.LastName(); //"Rummings"
Fake.Booleans(); //true
Fake.Word(); //"skillful"
Fake.Street(); //"Westport"
Fake.Location(); //{ postal_code: 20136, city: 'Bristow', state: 'VA' }
Fake.State(); //"OH"
Fake.Brand(); //"Cardguard"
Fake.Password(); //"hDtI4B6P7Sgb"
Fake.Phone(); //"(595) 1814321"
Fake.Job(); //"Research Nurse"
Fake.Avatar(); //"https://robohash.org/etvoluptasquae.bmp?size=50x50&set=set1"
Fake.Username(); //"aklimeckifn"
Fake.Price(); //"$50.17"
Fake.Size(); //['XXXS', 'XXS', 'XS', 'S', 'M', 'L', 'XL',  'XXL', 'XXL']
Fake.Paragraph(); //Praesent id massa id nisl venenatis lacinia. Aenean sit amet justo. Morbi...

Examples and pratical use cases

Create a basic object

const Fake = require("fake-things");

let signUp = {
  email: Fake.Email(),
  user_name: Fake.Username(),
  first_name: Fake.FirstName(),
  last_name: Fake.LastName(),
  password: Fake.Password(),
};

Create an array of objects

There are many ways of going about this. Here is an example to quickly get you going.

//import dependencies
const Fake = require("fake-things");

let signUpObj = {};
let signInArray = [];

//create a function to return a new object
let signUp = () => {
  return (signUpObj = {
    email: Fake.Email(),
    user_name: Fake.Username(),
    first_name: Fake.FirstName(),
    last_name: Fake.LastName(),
    password: Fake.Password(),
  });
};

//initialize a for loop to push the new object into the array.
for (let i = 0; i < 5; i++) {
  signInArray.push(signUp());
}

console.log(signInArray);
1.0.1

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago