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

dummy-json-js

v0.1.1

Published

Generate dummy json data. As file or object.

Downloads

7

Readme

dummy-json-js

Description

This is a npm package to create json dummy data.

How to use

Import module

First import the module.

const {Type, generateJSONDummy, generateJSONDummyArray} = require("dummy-json-js")

Define format

To generate json dummy data you need to define the format the data should be. The format contains of the key you want to name the entry, as well as the type of data.

let dummyDataConfig = {
    "stringKey": {"type": Type.String},
    "numberKey": {"type": Type.Number},
    "booleanKey": {"type": Type.Boolean},
    "nullKey": {"type": Type.Null}
}

You can also add explicit configurations to some Types. These options are available: | Type | options name | default-value | example | | :--- | :--- | :--- | :--- | | String | length | 10 | "length": 123 | | Number | limit | 100 | "limit": 200 | | Integer | limit | 100 | "limit": 200 | | Boolean | chance | 0.5 | "chance": 0.1 | | StreetNumber | includeLetter | false | "includeLetter": true|

Example:

let dummyDataConfigExplicit = {
    "stringKey": {"type": Type.String, "length": 123},
    "numberKey": {"type": Type.Number, "limit": 200},
    "integerKey": {"type": Type.Integer, "limit": 200},
    "booleanKey": {"type": Type.Boolean, "chance": 0.1},
    "streetNumberKey": {"type": Type.StreetNumber, "includeLetter": true}
}

Generate a single json object

To generate a single object use the function generateJSONDummy, and parse the data config object.

const {Type, generateJSONDummy} = require("dummy-json-js")

let dummyDataConfigExplicit = {
    "stringKey": {"type": Type.String, "length": 123},
    "numberKey": {"type": Type.Number, "limit": 200},
    "booleanKey": {"type": Type.Boolean, "chance": 0.1},
    "nullKey": {"type": Type.Null}
}

dummyData = generateJSONDummy(dummyDataConfigExplicit)

Generate a array of json objects

To generate a array of json objects use the function generateJSONDummyArray, and parse the data config object. You can also parse the number of elements the array should contain, default is 2.

const {Type, generateJSONDummyArray} = require("dummy-json-js")

let dummyDataConfigExplicit = {
    "stringKey": {"type": Type.String, "length": 123},
    "numberKey": {"type": Type.Number, "limit": 200},
    "booleanKey": {"type": Type.Boolean, "chance": 0.1},
    "nullKey": {"type": Type.Null}
}

dummyDataArray = generateJSONDummyArray(dummyDataConfigExplicit)

Data Types

String

Selector: Type.String

Example output: 'cTaGzkrOFD'

Options: | options name | default-value | example | | :--- | :--- | :--- | | length | 10 | "length": 123 |

Decimal number

Selector: Type.Number

Example output: 34.969813298829244

Options: | options name | default-value | example | | :--- | :--- | :--- | | limit | 10 | "limit": 200 |

Integer

Selector: Type.Integer

Example output: 34

Options: | options name | default-value | example | | :--- | :--- | :--- | | limit | 10 | "limit": 200 |

Boolean

Selector: Type.Boolean

Example output: true

Options: | options name | default-value | example | | :--- | :--- | :--- | | chance | 0.5 | "chance": 0.1 | 0.6 = 60% percent chance to get true

Null

Selector: Type.Null

Output: null

FirstName

Selector: Type.FirstName

Example output: 'Noah'

LastName

Selector: Type.LastName

Example output: 'Miller'

Company

Selector: Type.Company

Example output: 'Krani'

Street

Selector: Type.Street

Example output: 'Industrial Dr'

Streetnumber

Selector: Type.Streetnumber

Example output: 125

Options: | options name | default-value | example | | :--- | :--- | :--- | | includeLetter | false | "includeLetter": true | include letters at end of streetnumber

City

Selector: Type.City

Example output: 'Miami'

PostalCode

Selector: Type.PostalCode

Example output: '16057' PostalCodes may also end with letters

Country

Selector: Type.Country

Example output: 'Sweden'

Continent

Selector: Type.Continent

Example output: 'Europe'