Necessary Pigeonholing Mechanism

    random-profile-generator

    2.3.0 • Public • Published

    Random Profile Generator

    NPM

    Travis Codacy Badge Codecov npm npm npm npm semantic-release

    Generates a random user profile with all the common user profile items such as name, address, profile image etc. You can generate a complete profile or a generate individual profile properties such as name or address.

    Install

    Install the package using npm

    npm install random-profile-generator
    

    this will install the package to your node_modules folder

    Usage

    After installing import the package in to your javascript code.

    var randomProfile = require('random-profile-generator');

    API Documentation

    profile()

    Returns a randomly generated user profile with fullName, firstName, lastName, birthday, age, avatar, address, phone, email and twitter as properties of the profile object. Example usage is bellow.

    var profile = randomProfile.profile();
    console.log(profile);
     
    // Output
    /*
        id: 'dc3800ea-0ae8-592a-bcd6-2012667c3ccc',
        fullName: 'Della Edwards',
        firstName: 'Della',
        lastName: 'Edwards',
        gender: 'Male',
        birthday: 'Mar 24th, 1959',
        age: 57,
        avatar: 'https://api.adorable.io/avatars/200/Della-Edwards',
        address: '49 Foxrun St., Manchester Township, NJ 08759',
        zip: '08759',
        state: 'NJ',
        phone: '(876) 547-1223',
        email: 'cedi@to.cc',
        twitter: '@wunwegda',
        ssn: '744-48-5102'
    }
    */

    Also, profile supports generating Male or Female profiles by providing an argument. Argument must be string.

    Calling with argument male

    var profile = randomProfile.profile('male');
    console.log(profile);
     
    // Output
    /*
        id: '137b6d33-51f2-5994-8250-92667dc5679d',
        fullName: 'Emerson Nicholson', // <= Fullname is MALE name.
        firstName: 'Emerson',
        lastName: 'Nicholson',
        gender: 'Male', // <= Gender is MALE
        birthday: 'Jan 29th, 1965',
        age: 51,
        avatar: 'https://api.adorable.io/avatars/200/Emerson-Nicholson',
        address: '431 Front St., Eastpointe, MI 48021',
        zip: '48021',
        state: 'MI',
        phone: '(362) 561-9961',
        email: 'zu@culdisrik.lk',
        twitter: '@ig',
        ssn: '981-02-7670' 
    }
    */

    Calling with argument female

    var profile = randomProfile.profile('female');
    console.log(profile);
     
    // Output
    /*
        id: 'b0443ec8-4a00-55aa-8f74-6af0b6c26e17',
        fullName: 'Julie Lewis', // <= Fullname is FEMALE name.
        firstName: 'Julie',
        lastName: 'Lewis',
        gender: 'Female', // <= Gender is FEMALE
        birthday: 'May 15th, 1979',
        age: 37,
        avatar: 'https://api.adorable.io/avatars/200/Julie-Lewis',
        address: '234 E. Bridle Ave., Gloucester, MA 01930',
        zip: '01930',
        state: 'MA',
        phone: '(766) 519-6284',
        email: 'ruszon@mo.et',
        twitter: '@seef',
        ssn: '000-46-2316'
    }
    */

    name()

    Returns a random name with first name and last name. Also can provide string arguments male or female to return a Male or Female name.

    var name = randomProfile.name();
    console.log(name);
     
    // Output
    // => Michael Ruiz
     
    var maleName = randomProfile.name('male');
    console.log(maleName);
     
    // Output
    // => Emerson Nicholson
     
    var femaleName = randomProfile.name('female');
    console.log(femaleName);
     
    // Output
    // => Julie Lewis

    gender()

    Returns a random gender, return value being Male or Female

    var gender = randomProfile.gender();
    console.log(gender);
     
    // Output
    // => Male // or Female

    address()

    Returns a random address with street, city, State and Zip Code

    var address = randomProfile.address();
    console.log(address);
     
    // Output
    // => 87 North Constitution Circle, Rochester, NY 14606

    zip()

    Returns a random US Zip code

    var zip = randomProfile.zip();
    console.log(zip);
     
    // Output
    // => 14606

    state()

    Returns a random 2 letter abbreviation for US state

    var state = randomProfile.state();
    console.log(state);
     
    // Output
    // => NY

    birthday()

    Returns a random birthday in the MMM Do[,] YYYY format.

    var birthday = randomProfile.birthday();
    console.log(birthday);
     
    // Output
    // => Mar 12th, 1991

    age()

    Returns a random age.

    var age = randomProfile.age();
    console.log(age);
     
    // Output
    // => 25

    avatar()

    Returns a random avatar url generated from adorable.io API with a 200 x 200px size.

    var avatar = randomProfile.avatar();
    console.log(avatar);
     
    // Output
    // => https://api.adorable.io/avatars/200/Wendy-Conner

    phone()

    Returns a random phone number with US Phone Number Format.

    var phone = randomProfile.phone();
    console.log(phone);
     
    // Output
    // => (717) 238-3496

    email()

    Returns a random syntactically valid email address.

    var email = randomProfile.email();
    console.log(email);
     
    // Output
    // => cin@unepwa.cx

    ssn()

    Returns a random SSN.

    var ssn = randomProfile.ssn();
    console.log(ssn);
     
    // Output
    // => 411-90-0070

    twitter()

    Returns a random twitter handle.

    var twitterHandle = randomProfile.twitter();
    console.log(twitterHandle);
     
    // Output
    // => @hanaha

    guid()

    Returns a random GUID.

    var guid = randomProfile.guid();
    console.log(guid);
     
    // Output
    // => b0443ec8-4a00-55aa-8f74-6af0b6c26e17

    Contributing

    All contributions from the GitHub community are welcome.

    • Fork the repository
    • Create a feature branch: git checkout -b new-feature
    • Commit your changes: npm run commit (Uses Commitizen Conventional Changelog for commits)
    • Push to the branch: git push origin new-feature
    • Submit a Pull Request

    Installing Dependencies

    # install dependencies listed in package.json 
    $ npm install

    Run Unit Tests Locally

    # Run mocha tests with -w flag 
    $ npm run test:local

    Code Coverage

    Istanbul is used for code coverage analisys. nyc command-line client is used to support ES6 with babel as the transpiler. To run unit tests with code coverage report, use the following command.

    # Unit tests with code coverage 
    $ npm run cover

    Code Quality

    Codacy is configured on Github for code quality analisys.

    Git Commit Guidelines

    A strict commit guidelines are followed so that its easy to do release with semantic versioning. Semantic Release package is used to do this. Commitizen is used with Commitizen Conventional Changelog to add proper commit messages. Git hooks created using ghooks are inplace to enforce the commit format used in the project. Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject. The commit message format is bellow.

    <type>(<scope>): <subject>
    <BLANK LINE>
    <body>
    <BLANK LINE>
    <footer>
    

    Header is mandatory and the scope is optional, But its encouraged to add a scope. Footer is also optional. To perform a commit follow these steps

    # Add the files you want to commit 
    $ git add <FILES_TO_COMMIT>
     
    # Use the configured ghook 
    $ npm run commit

    Credits

    Random Profile Generator uses some 3rd party packages and APIs for its development. Credit goes to their creators & contributors.

    • Adorable.io - Adorable.io API is used to generate the avatar image included in the generated profile.
    • Chancejs - Chance is used to generate some of the values found in the generated profile.
    • MomentJs - MomentJs is used for some date conversions used in the generated profile.
    • Random Name Generator - Used to generate the random names used in the project.
    • Random Lists - Used to generate the US addresses used in the project.

    License

    MIT © Kasun Kodagoda

    Install

    npm i random-profile-generator

    DownloadsWeekly Downloads

    257

    Version

    2.3.0

    License

    MIT

    Last publish

    Collaborators

    • kasunkv