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

easy-breezy-data-generator

v1.0.2

Published

A generator to generate random but valid data using customized schema

Downloads

2

Readme

Easy-breezy Data Generator

This is a package which helps user to create a random dataset for any customized schema (Internally this package uses chance.js).

What's chance.js?

Chance is a generator of random strings, numbers etc. It helps reduce some mmonotony particulary while writing any automated tests or anywhere else you need anything random everytime.

How it works??

Generating data on the customized schema was a challenge earlier, But is no longer now :). In this package, we are going to see how you can generate a dataSet providing schema of your choice.!

How to configure your schema?

Simply customized your schema specifying your kinds (types). Types can be email, natural number, paragraph etc.. (find list of supported kinds at the end of this article.). Random data is an integral part of any testing or statistical modeling. They play an increasing important role in the system. And having control over the modelling/structuring of data would be cherry on the cake. So lets control the structuring of data by passing any variations of fields, arrays and objects in just one file. Below is the test schema.json for reference.

{
  "email": {
    "kind": "email",
    "params": {
      "domain": "test.com"
    }
  },
  "age": {
    "kind": "age",
    "params": {
      "type": "adult"
    }
  },
  "company": {
    "type": "object",
    "fields": {
      "companyName": {
        "kind": "company"
      },
      "companyAddress": {
        "kind": "address"
      },
      "companyDetails": {
        "type": "object",
        "fields": {
          "companyId": {
            "kind": "fbid"
          },
          "employeeCount": {
            "kind": "natural",
            "params": {
              "min": 1,
              "max": 20
            }
          },
          "subjects": {
            "type": "array",
            "count": 2,
            "fields": {
              "subjectName": {
                "kind": "word"
              },
              "marks": {
                "kind": "natural",
                "params": {
                  "min": 1,
                  "max": 100
                }
              }
            }
          }
        }
      }
    }
  },
  "firstName": {
    "kind": "first"
  },
  "lastName": {
    "kind": "last"
  },
  "subjects": {
    "type": "array",
    "count": 6,
    "fields": {
      "subjectName": {
        "kind": "word"
      },
      "marks": {
        "kind": "natural",
        "params": {
          "min": 1,
          "max": 100
        }
      }
    }
  }
}

You must be wondering what's this params parameter, these are optional parameters which chance.js uses for configuring you're kinds. Take the example of an email kind, it accepts domain parameter as params.

NOTE: By the way, this is just a sample schema.json, you can create your own using any combination of arrays or objects, which ever way you want it!

How to use?

  1. Install easy-breezy-data-generator from npm:
npm install easy-breezy-data-generator
  1. Import the package and schema, in whichever file you need it.
const DataGenerator = require('easy-breezy-data-generator');
const schema = require('./schema.json');
  1. Finally initialize and generate the random dataSet
const dataGenerator = new DataGenerator(schema);
console.log(JSON.stringify(dataGenerator.generateData()));

Below are some most used kinds. Also don't forget to checkout, all the different kinds provided by [chance.js] (https://chancejs.com/).

  1. bool
  2. falsy
  3. character
  4. floating
  5. integer
  6. letter
  7. natural
  8. prime
  9. string
  10. paragraph
  11. sentence
  12. syllable
  13. word
  14. age
  15. birthday
  16. cf
  17. cpf
  18. first
  19. gender
  20. last
  21. name
  22. prefix
  23. ssn
  24. suffix
  25. animal
  26. android_id
  27. apple_token
  28. bb_pin
  29. wp7_anid
  30. wp8_anid2
  31. avatar
  32. color
  33. company
  34. domain
  35. email
  36. fbid
  37. google_analytics
  38. hashtag
  39. ip
  40. ipv6
  41. klout
  42. profession
  43. tld
  44. twitter
  45. url
  46. address
  47. altitude
  48. areacode
  49. city
  50. coordinates
  51. country
  52. depth
  53. geohash
  54. latitude
  55. locale
  56. longitude
  57. phone
  58. postal
  59. postcode
  60. province
  61. state
  62. street
  63. zip
  64. ampm
  65. date
  66. hammertime
  67. hour
  68. millisecond
  69. minute
  70. month
  71. second
  72. timestamp
  73. timezone
  74. weekday
  75. year
  76. cc
  77. cc_type
  78. currency
  79. currency_pair
  80. dollar
  81. euro
  82. exp
  83. exp_month
  84. exp_year
  85. capitalize
  86. mixin
  87. pad
  88. pick
  89. pickone
  90. pickset
  91. set
  92. shuffle
  93. coin
  94. dice
  95. guid
  96. hash
  97. hidden
  98. n
  99. normal
  100. radio
  101. rpg
  102. tv
  103. unique
  104. weighted