random-user-generator
v0.2.0
Published
Random user generator using the randomuser.me services. It can bea single user or an array and outputs to the console or a file.
Downloads
10
Maintainers
Readme
random-user-generator
Random user generator using the randomuser.me services. It can be a single user or an array and outputs to the console or a file.
Install
$ npm install --save random-user-generator
Usage
var RandomUserGenerator = require('random-user-generator');
var rug = new RandomUserGenerator();
rug.getOne(function (user) {
console.log(user);
});
API
getOne
Returns one random user.
options (optional): Specifies a list of options (see section options) cb: A callback function that executes after the user was created. The parameter for the callback is the single user object
getMany
Returns an array of random users.
howMany: Specifies the number of users to return. options (optional): Specifies a list of options (see section options) cb: A callback function that executes after the user was created. The parameter for the callback is the single user object
Options
These are the options that you can pass either to the constructor or to the individual get* call.
fields
Specifies the list of fields that the returned users should have out of the default list of fields provided by randomuser.me
randomUserGenerator.getOne({fields: ["name", "email"]}, function (user) {
console.log(user);
/**
* Outputs
* {
* name:
* {first: "allan", last: "collins", title: "mr"},
* email: "[email protected]"
* }
**/
});
map
Creates a map for the fields to be returned.
randomUserGenerator.getOne({
map: {
firstName: "name.first",
email: "email",
telephone: "phone"
}
}, function (user) {
console.log(user);
/**
* Outputs
* {
* firstName: "allan",
* email: "[email protected]",
* telephone: "04-3108-4901"
* }
**/
});
writeToFile
If set to anything different than false, this will generate a file using the string passed as a parameter as the file name.
seed
Specify a seed to pass in the query paramter (see http://randomuser.me/documentation for details)
nationality
Specify a nationality to pass in the query paramter (see http://randomuser.me/documentation for details)
gender
Specify a gender to pass in the query paramter (see http://randomuser.me/documentation for details)
License
MIT © Joel Lord