{"_id":"@alexterliuk/data-gen","_rev":"2-342cc3b7bd7a575bc4842c12e9fcb513","name":"@alexterliuk/data-gen","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@alexterliuk/data-gen","version":"1.0.1","description":"Data generator. Give data, get back N instances with values - default or randomized according to options.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/alexterliuk/data-gen.git"},"author":{"name":"Alex Terliuk","email":"alex.terliuk@gmail.com"},"license":"MIT","homepage":"https://github.com/alexterliuk/data-gen","keywords":["data-generator","datagen","data-gen","randomizer","randomization","copy"],"gitHead":"02aed0d043a983a9e770cb1fed28fcb96736f562","bugs":{"url":"https://github.com/alexterliuk/data-gen/issues"},"_id":"@alexterliuk/data-gen@1.0.1","_nodeVersion":"13.10.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-gfXnBIbS+PHTG8mFffHVNPY9064F86Kb8U7BrKO5w6SoORa0p5q1nDApTEDPwxxv5bcVQO0XX9cFsaQhiWKRhQ==","shasum":"dbb606d08e160306b1d3ae3d942497a9eb29eeb3","tarball":"https://registry.npmjs.org/@alexterliuk/data-gen/-/data-gen-1.0.1.tgz","fileCount":33,"unpackedSize":260292,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaS81CRA9TVsSAnZWagAATNEP/RbWjhqPhE1hKAsEKO7i\n4sMCNYfUBGFldjFgtQU/PT6x4xRaVet6Pf7kfZPqFcEMEPJ6nWCiTkWd32ry\npsePGliyyOWwwd8XM8n/qDMdjvFgb150kP2lyA0xUS/dIZmgWa8Wy3MUfbW9\nq1sDKcSlCAKqhKTA5CtC7h2QCZ4G6mqGUfZ7q64Uxeil9lTGHoNibniUdQD/\nZ2IeU0ligetPPoik3KSe+JZsYHJf7rioe811Iy24+y3PrYPQHDr24ooogT01\nY/3eR9IsNFf/nM7J/0qf6WJ64NChMVzi19Ojd8PcTmRY9z/a4onnGk8iXTIa\nKRhmBHQOoDT6/wP9zWGIz0JvHUCZnbTiKxVzb8HgYcBnF/ZkBoAHtEFaf5/a\nMtMLt/MAApqpbMAX5zjb4D26BRS/wwC02qZWWLm7w9UnI8xE62uUxS1r2UI9\nMeGTH1sDdoD6qVzdpt8Z5HXmpTTqpLse33IkScPP85z5Zxhp+PavGDJZ/8X1\nrHm28W1dibmOJ3fSXY4oK4kMp08iFoXrWWxYNXq/qv9pTRSMAySWfoktu3+w\nJIy2XQbqHPWw+G1ykBkXcNyqfGkoDqzG+rAsLF/OY1Cp1dDZaZnq0nvpb3gh\ngwhGYomiXcLgABpJ/ZlCqsfP9lWXAk+MMLtJnPHvPeStzlauA3gTxpFFQNo6\nNZuf\r\n=IABT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqlYsk0SAtQvUM0AK51Mh69dJEhGbY8lIXK+Zhu+guMwIgLO0KhOoS7f/5lOYMFapaWooq1RMsTawwyNxLCHlJb1M="}]},"maintainers":[{"name":"alexterliuk","email":"alex.terliuk@gmail.com"}],"_npmUser":{"name":"alexterliuk","email":"alex.terliuk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/data-gen_1.0.1_1600728885256_0.2510313401459525"},"_hasShrinkwrap":false},"1.0.2":{"name":"@alexterliuk/data-gen","version":"1.0.2","description":"Data generator. Give data, get back N instances with values - default or randomized according to options.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/alexterliuk/data-gen.git"},"author":{"name":"Alex Terliuk","email":"alex.terliuk@gmail.com"},"license":"MIT","homepage":"https://github.com/alexterliuk/data-gen","keywords":["data-generator","datagen","data-gen","randomizer","randomization","copy"],"gitHead":"4ef89f021474f4ece021d4324ae1b948cd6d1ac9","bugs":{"url":"https://github.com/alexterliuk/data-gen/issues"},"_id":"@alexterliuk/data-gen@1.0.2","_nodeVersion":"13.10.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-fG5QzGKYNBsn2X2pvGbEPRAkunI/yTDGywUmigOopAar6uk96XHCSO828V9+IwSbSuQfN+Cg9hGSST9lO1rXZQ==","shasum":"d577c2497cc9fd9b83d1dfde598ba37723ce25bd","tarball":"https://registry.npmjs.org/@alexterliuk/data-gen/-/data-gen-1.0.2.tgz","fileCount":33,"unpackedSize":260366,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaTPiCRA9TVsSAnZWagAACFUP/ieKSqw9YOLkthjl+jl2\ntX2CvLm23TVpAnUNlN6mBBXK3+ku+r8uOKhkTrgdtGSDLV95DDSrNcPnDhJo\nT1/3cv3dsYSS8eMc35lLD9iHfXs22mtdusduoVpNooye1AQXJ9D/DS3gNctZ\nOIX3uoU9CPxpWFNuHZgL78MvXeUGxMi6AnO15VCtofAu62krkImXc4/Q6CxG\ngFLTQzD2kAs37nUdIEtCUr+7oQGiioBnIJUOvJm5XjHNMi+DEulx+qzEP/bl\nQmb+YkRiKpz3AzqB1TiZPiDGGLw03XKhiCFrCEyyBksoyPD+z4qr/RqEAyoi\n15Dg0Te2PYNH+1ZIbUnYfgvz7Omx0813ewvN+8Q/AiW5fR8m+e+wzC43uEAW\nkVXgUYbckj8YN5ImXrn/vbwEput+tComC/enB6vrQVRiZwoKY+XgH0/FZ4nK\ntevuFNftSRwnrXld59u0li0h24Ciw4d+6C/SSG333vKkqcaTyxhL+KsnDDKw\nyR2mytrBZiOxiVTvaNUzElplE0zJ5gugEcVrCiicxaw8+nIZ0FWRqAxzTOSA\n47ivLDqsi3Qn/7Qg9SN4cLaYtIIMWYsxEwx7FZnhPbnuKcLxrCXP7/1O/cYg\npD/+NWxX9U4elJCqlcwahaw/KwIqG5c5Yu00v2borcuQviYqovU8pzLd33+n\nSMI4\r\n=5393\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGmi1Bm1wwarlPNdTDbah9hZLbcxWbKUz013TrbnDJY3AiAU1I3GLU6VuBe9OIbbeuRCN3z6Iux4B7mMKrT/SPY9Hw=="}]},"maintainers":[{"name":"alexterliuk","email":"alex.terliuk@gmail.com"}],"_npmUser":{"name":"alexterliuk","email":"alex.terliuk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/data-gen_1.0.2_1600730081497_0.30247801121184037"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-21T22:54:45.222Z","1.0.1":"2020-09-21T22:54:45.395Z","modified":"2022-04-04T12:41:52.864Z","1.0.2":"2020-09-21T23:14:41.639Z"},"maintainers":[{"name":"alexterliuk","email":"alex.terliuk@gmail.com"}],"description":"Data generator. Give data, get back N instances with values - default or randomized according to options.","homepage":"https://github.com/alexterliuk/data-gen","keywords":["data-generator","datagen","data-gen","randomizer","randomization","copy"],"repository":{"type":"git","url":"git+https://github.com/alexterliuk/data-gen.git"},"author":{"name":"Alex Terliuk","email":"alex.terliuk@gmail.com"},"bugs":{"url":"https://github.com/alexterliuk/data-gen/issues"},"license":"MIT","readme":"> Clone data with same or random values.\n\n## Install\n\n```\nnpm i @alexterliuk/data-gen\n```\n\n## About\n\nDataGen is a cloning utility that creates _n_ instances of original data with the same or randomized values. It takes in `object` or `array`, traverses over all nested data and returns `array` with the desired quantity of instances that have the same structure. And what values created depends on the options you provided.\n\nFor example, given an input `{ weather: 'sunny', temp: 30 }`, you can get back `[{ weather: 'rainy', temp: 17 }, { weather: 'foggy', temp: 3 }]` if you specify such options. If no options provided, you will get instances with default values `{ weather: '', temp 0 }`.\n\nMaximum nesting level is 100, below it data is not processed. The restriction is set to avoid infinite loop in case if some child has its parent nested deeper in the tree.\n\n**TL;DR** - see examples in the end of this file.\n\n## Usage\n\n```\nconst DataGen = require('@alexterliuk/data-gen');\n\nconst task = {\n  id: 1784,\n  description: 'Write a novel',\n  completed: false,\n};\n\nconst options = {\n  quantity: 100,\n  byPath: [\n    {\n      path: 'id',\n      type: 'number',\n      name: 'makeRandomNumber',\n      data: { min: 1000, max: 9999 },\n    },\n    {\n      path: 'description',\n      type: 'string',\n      name: 'makeRandomText',\n      data: { minLength: 33, maxLength: 70 },\n    },\n  ],\n};\n\nconst newData = DataGen.make(task, options);\n// [\n//   { id: 7425, description: 'Unt lacus. Nulla gravida orci a odio. Nullam v', completed: true },\n//   { id: 3914, description: 'Ate velit esse cillum dolore eu fugia', completed: true },\n//   { id: 7719, description: 'Iquam faucibus, elit ut dictum al', completed: true },\n// ]\n```\n\n## Default values\n\nWhen a key - value pair is found inside input data it is checked whether options have an option for creating value for this path. If there is no option, default value is created. Default values for variative primitives are:\n\n  - boolean `true`\n  - number `0`\n  - string `''`\n\nFor other types their default values are they themselves:\n\n`[]`, `{}`, `null`, `/(?:)/`, `NaN`, `Infinity`, `undefined`\n\nIt means that if a value in data is `Infinity`, then `Infinity` is created, not 0 as number type. If empty object is found, new empty object is created. But if an object has data, it will be processed and appropriate key - values pairs will be created. The same logic is applied for arrays.\n\nSymbols and BigInts are ignored.\n\n## API\n\nThere are three public methods of DataGen.\n\n**make**\n\n`DataGen.make(data, options)`\n\n  - data - `object | array`\n  - options - `object`\n    - quantity - `string` (if omitted, no data will be created, empty `[]` is returned)\n    - lib - `object` (where you put your own data creating functions, if any; see examples)\n    - byPath - `array` (see **Options** section below)\n    - pathSyntax - `object`\n      - singleQuotes - `boolean` (if true - usages[\\'0'])\n      - doubleQuotes - `boolean` (if true - usages[\"0\"])\n      - squareBraced - `boolean` (if true - \\['usages']['0'] or \\[\"usages\"][\"0\"])\n\nIt makes *n* instances of data where *n* is `number` specified in options.quantity. Created data is returned inside `array`. If no options.quantity given, it returns empty `array`.\n\nIf no pathSyntax is given, default format for specifying path in option.path is - `x.someProp[0]`.\\\nIf *singleQuotes: true* is set, path format is - `x.someProp['0']`.\\\nIf *doubleQuotes: true* - `x.someProp[\"0\"]`.\\\nIf *squareBraced: true, singleQuotes: true* - `['x']['someProp']['0']`.\\\nIf *squareBraced: true, doubleQuotes: true* - `[\"x\"][\"someProp\"][\"0\"]`.\n\nThere's no need to add absolute path, relative is enough - `someProp[0]` or even `[0]` will work. But if your data has many similar paths you can expand your path, adding parent segments, until option.path becomes unique.\n\nIn options.lib you can add your own functions for creating data. This is convenient when you don't want to use built-in *makeRandomSmth* functions. For example, you can make *options.lib = { myOwnFunc: () => {}}*, and in *options.byPath[0]* instead of `{ type: 'number', path: 'somePath', name: 'makeRandomNumber', data: ...}` you can give `{ type: 'number', path: 'somePath', name: 'myOwnFunc' }` and your function will be called for creating data for this path. See also an example in **Examples** section below.\n\n**test**\n\n`DataGen.test(data, options)`\n\nIt is the wrapper for DataGen.make to switch on logging mode when along with data creation each step of this process is shown in the terminal. Logging may be customized by adding settings in options.testing.\n\n  - options.testing - `object`\n    - maxSpaceLength - `number` (width between columns; default is 30)\n    - keepDataTypes - `boolean` (log values as strings | their types; default is false)\n    - showAllNewVals - `boolean` (show all created values of the current path, so it is convenient to have them in one place aggregated for examining; default is false - only the first value is shown)\n\nkeepDataTypes and showAllNewVals testing options don't work in Node.js environment.\n\n**testBuiltIn**\n\n`DataGen.testBuiltIn(?...entities)`\n\nThis method lets you test built-in logic of DataGen. An entity is the name of a function or a procedure to test. If no entity is given, then all built-in logic is tested and the result is logged in the terminal.\n\n  - ...entities - `strings`\n    - DataGenCalling\n    - valueChecker\n    - helper\n    - makeRandomNumber\n    - makeRandomName\n    - makeRandomText\n    - makeRandomDateTime\n___\n\n**Options**\n\nIt is the `object` which you pass into **make** or **test**. In addition to the general settings mentioned above, you can specify options for creating randomized values for desired paths. These options are added to byPath collection.\n\n**options.byPath**\n\nType: `array<objects>`\n\nEach option inside options.byPath is `object` which has such structure.\n\n| prop | type | description |\n|:----:|:--------:|-------|\n| type | `string` | type of a value to be created |\n| name | `string` | name of a function responsible for creating the value |\n| path | `string` | path where the value in original data is located |\n| data | `object` | settings for a function which is specified in *name* |\n\nThere are 4 built-in functions which randomize values. Below are settings for them which you place inside option.data.\n\n**makeRandomNumber**\n\n  - min - `number`\n  - max - `number`\n  - digitsAfterFloatingPoint - `number`\n\nThus, you can set a range within which a new number will be randomly created, and whether it should be integer or float. If you give *min*, you should also give *max* and vice versa, otherwise 0 is returned. If *min* > *max*, values are automatically swapped, so *min* becomes *max* and *max* becomes *min*.\n\n---------- text-specs ----------\n\noption.data for next two functions - makeRandomText, makeRandomName - has similar structure which is aggregated into text-specs.\n\n<*text-specs*> - `object`\n\n  - minLength - `number`\n  - maxLength - `number`\n  - capitalizeFirstLetter - `boolean` (true by default)\n  - capitalizeAllLetters - `boolean`\n  - collection - `array<strings>` (make text from given texts; if present, no other prop of text-specs is checked, because they aren't needed)\n\n**makeRandomText**\n\n  - ...<*text-specs*>\n  - startFromBeginning - `boolean` (slice from start of text sample, false by default)\n\nThis function has a built-in dummy text sample from which random parts are being sliced to compose a new text within specified min/maxLength. If collection is provided, built-in text sample is ignored and a new text is created from randomly picked strings inside the collection.\n\n**makeRandomName**\n\n  - alphabet - `string` (from which to slice chars randomly; if omitted English is used)\n  - allNames - `object`\n    - alphabet\n    - namesInCompoundName - `number`\n    - ...<*text-specs*>\n  - name1, name2 etc. - `objects`\n    - alphabet\n    - ...<*text-specs*>\n\nIf option.data has allNames, then name1, name2 etc. are not checked. By namesInCompoundName you can specify how many names a full name should consist of. For example, if you want the name to have 3 names inside, you set *namesInCompoundName: 3* and provide a collection *['John', 'Lo', 'Brown']*, from which names are picked randomly (so, the full name might form as 'John Lo Brown' or 'Lo John Brown' or other combination). It there's no collection, 'Arwq Lkwpoar W' might form as a full name with length of each name to be within min/maxLength range.\n\nIf you want more freedom in customizing each name of a compound name, you don't need allNames. Instead you provide nameN specs, where N is `number`. The desired quantity of names is taken from counting nameN properties inside option.data. For example, you want that first name be 'John' or 'Laura', second - any, third - 'Brown'. So, you add name1 with a collection *['John', 'Laura']*, name2 with *minLength: 1* and *maxLength: 10*, name3 with a collection *[Brown]*. The result will be 'Laura Trk Brown' or 'John Usdrtwfg Brown' etc. \n\n**makeRandomDateTime**\n\n  - years - `array<numbers>` (if omitted, range 0-9999 is used)\n  - months - `array<numbers>`\n  - dates - `array<numbers>`\n  - hours - `array<numbers>`\n  - minutes - `array<numbers>`\n  - seconds - `array<numbers>`\n\nThis function creates datetime string of `YYYY-MM-DDThh:mm:ss` format. Each `array` in option.data holds desired `numbers` which should be used when constructing a datetime. Assume you want to get a datetime with a date to be 17 or 21. You specify *dates:[17, 21]* and get back a datetime with one of those two dates and random other segments. If no options.data given, datetime string will be completely random.\n\n## Examples\n\n**Make random names, numbers**\n\n```\nconst user = { name: 'John', age: 30 };\n\nconst options = { quantity: 3 };\noptions.byPath = [\n  {\n    type: 'string',\n    name: 'makeRandomName',\n    path: 'name',\n    data: {\n      name1: { minLength: 8, maxLength: 14 },\n    },\n  },\n  {\n    type: 'number',\n    name: 'makeRandomNumber',\n    path: 'age',\n    data: {\n      min: 0,\n      max: 122,\n    },\n  },\n];\n\nDataGen.make(user, options);\n\n// [\n//   { name: 'Phdyskth', age: 110 },\n//   { name: 'Mkbolfsvti', age: 56 },\n//   { name: 'Iffxfdwah', age: 54 },\n// ]\n```\n\n**Get names from a collection**\n\n```\nconst user = { name: 'John', age: 30 };\n\nconst options = { quantity: 3 };\noptions.byPath = [\n  {\n    type: 'string',\n    name: 'makeRandomName',\n    path: 'name',\n    data: {\n      name1: { collection: ['John', 'Kevin', 'Julia', 'Sophie'] },\n      name2: { collection: ['fon', 'der'] },\n      name3: { collection: ['Keflavik', 'Maroovski', 'Smith'] },\n    },\n  },\n];\n\nDataGen.make(user, options);\n\n// [\n//   { name: 'Julia fon Smith', age: 0 },\n//   { name: 'Sophie der Keflavik', age: 0 },\n//   { name: 'Kevin fon Keflavik', age: 0 },\n// ]\n```\n\n**Make different numbers**\n\n```\nconst pos = { x: 4, y: 17, z: 93 };\n\nconst options = { quantity: 3 };\noptions.byPath = [\n  {\n    type: 'number',\n    name: 'makeRandomNumber',\n    path: 'x',\n    data: { min: 4, max: 4 },\n  },\n  {\n    type: 'number',\n    name: 'makeRandomNumber',\n    path: 'y',\n    data: { min: -100, max: 50 },\n  },\n  {\n    type: 'number',\n    name: 'makeRandomNumber',\n    path: 'z',\n    data: { min: 100, max: 1000, digitsAfterFloatingPoint: 3 },\n  },\n];\n\nDataGen.make(pos, options);\n\n// [\n//   { x: 4, y: -3, z: 107.241 },\n//   { x: 4, y: 14, z: 525.998 },\n//   { x: 4, y: -55, z: 807.082 },\n// ]\n```\n\n**Make random text**\n\n```\nconst items = [{ id: '1o9p', description: 'BW item' }, { id: 'sl4q', description: 'Color item' }];\n\nconst options = { quantity: 3 };\noptions.byPath = [\n  {\n    type: 'string',\n    name: 'makeRandomText',\n    path: '[0].description',\n    data: { minLength: 5, maxLength: 30 },\n  },\n  {\n    type: 'string',\n    name: 'makeRandomText',\n    path: '[1].description',\n    data: { collection: ['Awesome description', 'Impressions you might want to try', 'Driver'] },\n  },\n  {\n    type: 'string',\n    name: 'makeRandomName',\n    path: 'id',\n    data: { alphabet: 'abcdefghijkl1234567890',\n            name1: { minLength: 4, maxLength: 4, capitalizeFirstLetter: false } },\n  },\n];\n\nDataGen.make(items, options);\n\n// [\n//   [\n//     { id: '4807', description: 'M dolore eu fu' },\n//     { id: 'ig54', description: 'Impressions you might want to try' },\n//   ],\n//   [\n//     { id: 'g3hf', description: 'Risus vulputate vehic' },\n//     { id: 'f5e5', description: 'Awesome description' },\n//   ],\n//   [\n//     { id: 'l0ci', description: 'C fermentum. Pellentesque m' },\n//     { id: '5eaj', description: 'Awesome description' },\n//   ],\n// ]\n```\n\n**Make random datetime**\n\n```\nconst options = { quantity: 3 };\noptions.byPath = [\n  {\n    type: 'string',\n    name: 'makeRandomDateTime',\n    path: 'dt',\n    data: { years: [2020], minutes: [58, 59] },\n  },\n];\n\nDataGen.make({ dt: '' }, options);\n\n// [\n//   { dt: '2020-07-13T20:59:36' },\n//   { dt: '2020-09-01T16:58:31' },\n//   { dt: '2020-06-18T07:58:23' },\n// ]\n\n// - - - - - - - - - - - - - - - - -\n\nfs.writeFileSync(\n  'new-data.json',\n  JSON.stringify(DataGen.make({ dt: '' }, options))\n);\n\n// [{\"dt\":\"2020-06-14T20:58:47\"},{\"dt\":\"2020-08-30T19:59:04\"},{\"dt\":\"2020-12-18T07:58:22\"}]\n```\n\n**Make complex data**\n\n```\nconst category = {\n  id: 1523,\n  name: '',\n  description: '',\n  date: '',\n  inUse: false,\n  items: [\n    {\n      itemName: 'Activation Matrix 1784 DBRS',\n      points: [14, -0.5498763145698756, 0],\n    },\n  ],\n  records: [\n    [258369, -123968, 700203],\n    [-4.25698, 8.01703, 3.15331],\n    [0, 1, -1, -1],\n  ],\n};\n\nconst optsData = [\n  ['number', 'number', 'id', { min: 1, max: 9999 }],\n  ['string', 'name', 'name', { allNames: { minLength: 5, maxLength: 15, namesInCompoundName: 3 } }],\n  ['string', 'text', 'description', { minLength: 100, maxLength: 200, startFromBeginning: true }],\n  ['string', 'dateTime', 'date', { years: [2020], months: [9], minutes: [0, 30], seconds: [0] }],\n  ['number', 'number', 'points[0]', { min: 10, max: 99 }],\n  ['number', 'number', 'points[1]', { min: -10, max: 0, digitsAfterFloatingPoint: 12 }],\n  ['number', 'number', 'points[2]', { min: 0, max: 0 }],\n  ['number', 'number', 'records[0][0]', { min: 100000, max: 500000 }],\n  ['number', 'number', 'records[0][1]', { min: -500000, max: -100000 }],\n  ['number', 'number', 'records[0][2]', { min: 500000, max: 999999 }],\n  ['number', 'number', 'records[1][0]', { min: -10, max: 10, digitsAfterFloatingPoint: 5 }],\n  ['number', 'number', 'records[1][1]', { min: -10, max: 10, digitsAfterFloatingPoint: 5 }],\n  ['number', 'number', 'records[1][2]', { min: -10, max: 10, digitsAfterFloatingPoint: 5 }],\n  ['number', 'number', 'records[2][0]', { min: -1, max: 1 }],\n  ['number', 'number', 'records[2][1]', { min: -1, max: 1 }],\n  ['number', 'number', 'records[2][2]', { min: -1, max: 1 }],\n  ['string', 'name', 'itemName',\n    {\n      name1: { collection: ['Activation', 'Hydration', 'Filtration'] },\n      name2: { collection: ['Matrix'] },\n      name3: { alphabet: '0123456789', minLength: 4, maxLength: 4 },\n      name4: { minLength: 4, maxLength: 4, capitalizeAllLetters: true },\n    },\n  ],\n];\n\nfunction makeOption(type, funcNameEnding, path, data) {\n  const f = 'makeRandom' + funcNameEnding[0].toUpperCase() + funcNameEnding.slice(1);\n  return { type, name: f, path, data };\n}\n\nfunction makeOptions(arr, qty) {\n  return {\n    quantity: qty,\n    byPath: arr.map(d => makeOption.call({}, ...d)),\n  };\n}\n\nconst options = makeOptions(optsData, 100);\n\nfs.writeFileSync(\n  'new-data.json',\n  JSON.stringify(DataGen.make(category, options))\n);\n\n// or if you want to log data creation process in the terminal, use test method\n// DataGen.test(category, { testing: { keepDataTypes: true, showAllNewVals: true }, ...options });\n\n// [{\n//   \"date\": \"2020-09-25T02:00:00\",\n//   \"description\": \"Lorem ipsum dolor sit amet, consectetur...\",\n//   \"id\": 6884,\n//   \"inUse\": true,\n//   \"items\": [{\n//     \"itemName\": \"Hydration Matrix 7829 VDAS\",\n//     \"points\": [26, -2.884532310826, 0]\n//   }],\n//   \"name\": \"Kubpsodfrpbpv Kbuaxeihyedves Yihktzdelc\",\n//   \"records\": [\n//     [200062, -242021, 730448],\n//     [-5.75639, -2.23289, 8.99108],\n//     [0, -1, 1, 0]\n//   ]\n// },\n// // ...  \n// ]\n```\n\n**Use own function from options.lib**\n\n```\nconst data = { price: {} };\n\nconst options = {\n  quantity: 100,\n  lib: {\n    makePrice: {\n      make: makePrice,\n      data: ['USD', 'EUR', 'GBP', 'YEN', 'CAD'],\n    },\n  },\n  byPath: [\n    {\n      type: 'object',\n      name: 'makePrice',\n      path: 'price',\n    },\n  ],\n};\n\nfunction makePrice(d) {\n  let rand = (Math.random() / 2 - 0.05) * 10;\n  rand = rand > 0 ? rand : 0;\n  const currency = d[Math.round(rand)];\n  const amount = +(Math.random() * 1000).toFixed(2);\n\n  return { currency, amount };\n}\n\nDataGen.make(data, options);\n\n// [\n//   { price: { currency: 'GBP', amount: 318.62 } },\n//   { price: { currency: 'GBP', amount: 175.81 } },\n//   { price: { currency: 'USD', amount: 320.51 } },\n//   { price: { currency: 'EUR', amount: 63.57 } },\n//   { price: { currency: 'CAD', amount: 364.55 } },\n// ...\n// ]\n```\n","readmeFilename":"README.md"}