1.0.2 • Published 2 years ago

dummy-json-datas v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Sample data is required for testing frontend apis for every project. Sometime api creation takes time however with using this package you can create random sample data and check the output.

Please check follwing example

install the repository by following command

npm i dummy-json-datas


actual coding

const dummy = require('dummy-json-datas');

let configuration = [

{key: "name", type : "string", minlength : 12, maxlength: 12, space : 1, case: "capitalize"},

{key: "pan", type : "alphanumeric", minlength : 12, maxlength: 12, space : 0, case: "uppercase"},

{key: "email", type : "email"},

{key: "mobile", type : "number", minlength : 10, maxlength: 10, space : 1},

{key: "description", type : "string", minlength : 100, maxlength: 50, space : 10, optional : true},

{key: "address", type : "object", structure: [

    {key: "city", type : "string", minlength : 4, maxlength: 10, space : 1},

    {key: "state", type : "string", minlength : 4, maxlength: 10, space : 1},

]}

];

const recordCount = 10;

const mydata = dummy.showdata(configuration, recordCount);

console.log(mydata);


Explanation :

Array can be created in number of records you can pass this value as following line :

const mydata = dummy.showdata(configuration, recordCount);

recordCount : number of objects needed

in configuration various parameters of array required :

{key: "name", type : "string", minlength : 12, maxlength: 12, space : 1, case: "capitalize"}

Here,

key : name of the object in array

type : variable type needed (possible values are : string, alphanumeric, number, email, object).

minlength : minimum length of value (numeric)

maxlength : maximum length of value (numeric)

space : space needed through entire output value (numeric)

case : case of output value (capitalize, uppercase, lowercase)

structure : object structure with array of parameters

optional : this has been set to true if it is optional parameter for object


Notes

Support only one depth array object of specific object.