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

mock-creator

v1.0.4

Published

Package for generating differend kinds of mocked data.

Downloads

7

Readme

mock-creator

Mock creator is npm package to create local mocks data fast and simple. It creates Array/Object/Value by passed configuration. Great for huge array mocks. Without copy/pasting data yourself.

Installation

Use npm/ yarn to install mock-creator.

npm install mock-creator --save

yarn add mock-creator

Usage

var { 
    generators,
    types,
 } = require('mock-creator');


const arrayConfig = {
    length: 5,
    fields: {
        id: {
            type: types.valueTypes.NUMBER,
            generatorType: types.generatorTypes.UNIQ,
        },
        age: {
            type: types.valueTypes.NUMBER,
            generatorType: types.generatorTypes.RANGE,
            range: [20, 30],
        },
        luckyNumber: {
            type: types.valueTypes.NUMBER,
            generatorType: types.generatorTypes.RANDOM,
        },
        staticName: {
            type: types.valueTypes.STRING,
            generatorType: types.generatorTypes.STATIC,
            value: 'Your Name',
        },
        randomString: {
            type: types.valueTypes.STRING,
            generatorType: types.generatorTypes.RANDOM,
        },
        uniqString: {
            type: types.valueTypes.STRING,
            generatorType: types.generatorTypes.UNIQ,
        },
        randomDate: {
            type: types.valueTypes.DATE,
            generatorType: types.generatorTypes.RANDOM,
        },
        dateInRange: {
            type: types.valueTypes.DATE,
            generatorType: types.generatorTypes.RANGE,
            range: [new Date(), new Date(2022, 10, 8)],
        }
    }
}

const results = generators.generateArray(arrayConfig);

console.log('results', results);

/**
OUTPUT WILL BE
results [
  {
    id: 0,
    age: 22,
    luckyNumber: 50629,
    staticName: 'Your Name',
    randomString: 'ANtr1lZ2m1HPIXd',
    uniqString: '0',
    randomDate: 2018-05-26T18:38:31.023Z,
    dateInRange: 2021-12-24T14:51:21.983Z
  },
  {
    id: 1,
    age: 29,
    luckyNumber: 1254,
    staticName: 'Your Name',
    randomString: 'YiXKFFuuXxtmmTk',
    uniqString: '1',
    randomDate: 2012-06-02T13:15:13.993Z,
    dateInRange: 2021-04-19T12:21:51.014Z
  },
  {
    id: 2,
    age: 26,
    luckyNumber: 72941,
    staticName: 'Your Name',
    randomString: 'UOkMqud7RnUJJeB',
    uniqString: '2',
    randomDate: 2018-03-31T11:35:37.485Z,
    dateInRange: 2021-04-11T21:29:20.458Z
  },
  {
    id: 3,
    age: 21,
    luckyNumber: 36390,
    staticName: 'Your Name',
    randomString: '25qB7QtWDz03gkx',
    uniqString: '3',
    randomDate: 2017-09-30T12:02:21.984Z,
    dateInRange: 2021-11-28T07:01:23.613Z
  },
  {
    id: 4,
    age: 21,
    luckyNumber: 75664,
    staticName: 'Your Name',
    randomString: 'dVQgm1UyE7vpCtD',
    uniqString: '4',
    randomDate: 2012-08-12T12:14:34.354Z,
    dateInRange: 2022-09-16T20:45:00.645Z
  }
]
**/

Methods

| Method | Type | parameters | Description |--------------------|-----------|---------------|------------------------------- | generateArray | function | configObject | Generates array of objects. | generateObject | function | configObject | Generates object. | generateValue | function | configObject | Generates value.

Constants

| Method | Type | Valid Values | Description |--------------------|-----------|------------------------------------------|------------------------------- | valueTypes | string | [ 'number', 'string', 'date' ] | Generates array of objects. | generatorTypes | string | [ 'uniq', 'static', 'random', 'range', 'one_of' ] | Could be imported from generatorTypes.

License

MIT