Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple means to generate user data.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
data
test
.gitignore
LICENSE
README.md
package.json
usergen.js

README.md

UserGen

This is a simple module that generates user data. Originally intended for testing purposes, some of the methods could be useful outside of testing, such as username generation.

Installation

If you're using it for testing (usual case):

npm install usergen --save-dev

Otherwise:

npm install usergen --save

Usage Example

Generating an entire user (to save to Mongoose, in this case):

// Require the module.
var usergen = require('usergen');

// Generate user data.
var user = usergen.user();

// Example use case: saving this user to Mongoose.
SomeAwesomeModel.create(user);

Generating a username with custom data:

var usergen = require('usergen');
var data = {
  Adj: [
    'Super',
    'Awesome'
  ],
  Verb: [
    'Jump',
    'Fly'
  ],
  Noun: [
    'Wizard',
    'Robot',
    'Zombie',
    'Ninja'
  ],
  pattern: {
    AdjNoun: 0.75,
    VerbingNoun: 0.25
  }
};

// Prints out the new username, rendered using `data`.
console.log(usergen.render(data));

Alternatives

  • randomuser.me - A fantastic service with the same purpose. The only reason this module exists is because I wanted the same simple, useful feature offline. I also didn't need some of the features, like the profile picture. If you're looking for more fields and don't need to run your tests offline, use this service.
Something went wrong with that request. Please try again.