npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spawn-it

v0.1.6

Published

A Node package for spawning random data.

Downloads

7

Readme

spawn-it logo

Build Status Coverage Status

Spawn-it is a node package for spawning random data.

###Installation

$ npm install spawn-it

###Features

  • Easy to use
  • Readable syntax

###Usage ####Example

var spawn = require('spawn-it');

var studentFirstName = spawn.string.names.firstName('male');
var studentLastName = spawn.string.names.lastName();
var gradePercentage = spawn.number.int.between(0, 100);

var test = {
  student: {
    firstName: studentFirstName,
    lastName: studentLastName
  },
  percentage: gradePercentage
};

####Only need a single module? Sometimes you only need part of the functionality. Spawn-it lets you do that.

var spawnNumber = require('spawn-it').number;

var myRandomInt = spawnNumber.int.between(-10, 10);

###Spawnable Data

Boolean

var spawn = require('spawn-it');

// simple - returns true or false
var randomBool = spawn.boolean.simple();

// array - returns an array of values (true or false) for a given length
var randomBools = spawn.boolean.array(length);

// coin flip - returns "heads" or "tails"
var randomSide = spawn.boolean.coinFlip();

// bit - returns 1 or 0
var randomBit = spawn.boolean.bit();
    

Color

var spawn = require('spawn-it');

// simple - returns a random color (hex)
var randomColor = spawn.color.simple();

// array - returns an array of random colors (hex)
var randomColors = spawn.color.array(length);

// hue
    // simple
    var randomHueColor = spawn.color.hue(hue).simple();
    
    // array
    var randomHueColors = spawn.color.hue(hue).array(length);
    
// luminosity
    // simple
    var randomLuminosityColor = spawn.color.luminosity(luminosity).simple();
    
    // array
    var randomLuminosityColors = spawn.color.luminosity(luminosity).array(length);
  
//hue and luminosity
    // simple
    var randomHueAndLuminosityColor = spawn.color.hueAndLuminosity(hue, luminosity).simple();
  
    // array
    var randomHueAndLuminosityColors = spawn.color.hueAndLuminosity(hue, luminosity).array(length);

Date

var spawn = require('spawn-it');

// weekday
    // name
    var randomWeekday = spawn.date.weekday.name();
    
    // abbr
    var randomWeekday = spawn.date.weekday.abbr();
    
    // number
    var randomWeekday = spawn.date.weekday.number();
    
    // allNames
    var randomWeekday = spawn.date.weekday.allNames();
    
    // allAbbrs
    var randomWeekday = spawn.date.weekday.allAbbr();
    
// month
    // name
    var randomMonth = spawn.date.month.name();
    
    // abbr
    var randomMonth = spawn.date.month.abbr();
    
    // number
    var randomMonth = spawn.date.month.number();
    
    // allNames
    var randomMonth = spawn.date.month.allNames();
    
    // allAbbrs
    var randomMonth = spawn.date.month.allAbbr();
    
// year
    // full
    var randomYear = spawn.date.year.full(min, max);
    
    // short
    var randomYear = spawn.date.year.short();
    
// decade
    // full
    var randomDecade = spawn.date.decade.full();
    
    // short
    var randomDecade = spawn.date.decade.short();
    
    // name
    var randomDecade = spawn.date.decade.name();

Number

var spawn = require('spawn-it');

// int
    // between
    var randomInt = spawn.number.int.between(min, max);
    
    // ofLength
    var randomInt = spawn.number.int.ofLength(length);
    
    // array
    var randomInts = spawn.number.int.array(length, intMin, intMax)
    
// decimal
    // between
    var randomDecimal = spawn.number.decimal.between(min, max, precision, asString);
    
    // ofLength
    var randomDecimal = spawn.number.decimal.ofLength(length, precision, asString);

Person

var spawn = require('spawn-it');

// names
    // first name
    var randomFirstName = spawn.person.names.firstName(gender);
    
    // last name
    var randomLastName = spawn.person.names.lastName();
    
// attributes
    // age
    var randomAge = spawn.person.attributes.age([min, max]);

Text

var spawn = require('spawn-it');

// char - case is optional
var randomChar = spawn.text.char(case);

// string
    // between
    var randomString = spawn.text.string.between(min, max);
    
    // ofLength
    var randomString = spawn.text.string.ofLength(length);
    
    // random
    var randomString = spawn.text.string.random();
    
// utility
  // capitalizeFirst
  spawn.text.utility.capitalizeFirst(string, toLowerBefore)

###Contributors Josh Taylor
Nathan Francy
Dylan Stanfield

###License MIT