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

create-test-data

v1.0.1

Published

Create test data in your work.

Downloads

5

Readme

create-test-data

NPM Version NPM Downloads

Features

  • A lib for create test data which you can use in javascript.

Installation

$ npm install create-test-data

before use

the default config like this:

const defaultOpts = {
*    key: '', // the object key, and create data will use it as key.
*    type: CONSTANT.TYPE[0], //data type, you can set it as one of ['string', 'number', 'numberic', 'email', 'url', 'float', 'idcard', 'html', 'chinese'].
*    max: CONSTANT.DEFAULT_MAX_NUM, // the value max length.
*    min: CONSTANT.DEFAULT_MIN_NUM, // the value min length.
    isFixed: true // if you set it true, the value is random in min to max. if false, the value will fixed.
};

how to use

ex1. use object as args and default config.(create data is all about string)

import { CreateTestData } from 'create-test-data';

const tplData = {aaa: 1, bbb: 2, ccc: 3}

const data = CreateTestData.createData(tplData);

//output:

{ aaa: '9rrRoAj1xN1RhEpK4ipZ',
  bbb: 'zNJpFoAJWkwxiRxz3b6P',
  ccc: 'nMs3e21YqrUpgeOc85e3' }

e2. use array as args and default config.(create data is all about string)

If you use array as args and the array element is not reach the specifications for the config, you will get the object will meger all element.

import { CreateTestData } from 'create-test-data';

const tplData = [{aaa: 1, bbb: 2, ccc: 3}, {qqq: 1, www: 2, eee: 3}]

const data = CreateTestData.createData(tplData);

//output:

{ aaa: 'eDLqRy3DwQYN1xJmqHAU',
  bbb: 'F4Dfu0AwM69odpuJFi8r',
  ccc: 't3rMe1EibyHSV8fMSxrA',
  qqq: '2D7hMbrl1maPyhksv7Di',
  www: 'fED83pQODvOtk2Ln3Nsg',
  eee: 'XPnts5D429OtsOehafNL' }

ex3. use config options.

import { CreateTestData } from 'create-test-data';

const data1 = CreateTestData.createData(
    {key: 'aaa', type: 'number', max: 10, min: 1}
);

const data2 = CreateTestData.createData(
    [{key: 'aaa', type: 'number', max: 10, min: 1}, {key: '',type:'string',max: 10, min: 2}]
);
// or

const data2 = CreateTestData.createData(
    [
        {key: 'aaa', type: 'number', max: 10, min: 1},
        {key: 'bbb', type: 'string', max: 10, min: 2},
        {key: 'ccc', type: 'string', max: 10, min: 2}
    ]
);

//or

const data3 = CreateTestData.createData(
    [
        {key: 'aaa', type: 'number', max: 10, min: 1},
        {key: 'bbb', type: 'string', max: 10, min: 2},
        {key: 'ccc', type: 'string', max: 10, min: 2},
        {ddd:2,fff:3,eee:4}
    ]
);

//out put
data1: 
    { 
        aaa: 979332569 
    }

data2: 
    {   aaa: 914083701, 
        bbb: 'EysBiTp1J', 
        ccc: 'LGCl73iYM' 
    }

ddd3: 
    { 
        aaa: 874249513,
        bbb: 'T5Rnb7SI91',
        ccc: 'U75Uc62',
        ddd: '7JOpIdz3Jsx85aKSKx7a',
        fff: 'Y5ffgIf10n5HevHRLu6Z',
        eee: 'GU2Nq8xILIkwcqMSEn0G' 
        
    }

The last.

If you have any question, you can submit issuse for me.

License

MIT