├── LICENSE ├── README.md ├── package.json ├── stubJs.html └── stubJs.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 me 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stubJs 2 | Js stub generator for creating **smart** dummy data 3 | 4 | ## Basic Usage 5 | 6 | ``` 7 | var data = stubJs( 'random(cat,dog,mouse,fish)', 5 ); 8 | 9 | // [ 'cat', 'fish', 'fish', 'dog', 'mouse' ]; 10 | ``` 11 | 12 | ## Objects / Arrays 13 | ``` 14 | var data = stubJs({ 15 | 16 | boolean : 'boolean', 17 | string : 'string', 18 | number : 'number', 19 | object : { number : 'number', string : 'string' }, 20 | array : ['number',10], 21 | date : 'date', 22 | color : 'color', 23 | animal : 'random(dog,cat,mouse,fish)', 24 | static : 'my static string', 25 | dynamic : 'my number is {{number(1,10)}}!' 26 | 27 | },2 ); 28 | ``` 29 | Resulting stub data : 30 | ``` 31 | [ 32 | { 33 | boolean : true, 34 | string : 'd32kj', 35 | number : 7, 36 | object : { number : 2, string : 'dsk2j' }, 37 | array : [ 1, 6, 9, 3, 6, 7, 2, 1, 6, 3 ], 38 | date : js Date object, 39 | color : '#32cc12', 40 | animal : 'dog', 41 | static : 'my static string', 42 | dynamic : 'my number is 7!' 43 | }, 44 | { 45 | boolean : false, 46 | string : '234jk', 47 | number : 2, 48 | object : { number : 1, string : '0dsal' }, 49 | array : [ 6, 2, 8, 1, 9, 1, 0, 1, 7, 7 ], 50 | date : js Date object, 51 | color : '#99aabb', 52 | animal : 'fish', 53 | static : 'my static string', 54 | dynamic : 'my number is 9!' 55 | } 56 | ] 57 | ``` 58 | 59 | ## Options 60 | 61 | * 'boolean' 62 | * 'string(length)' 63 | * 'number(min,max)' 64 | * 'object' 65 | * 'array / array of objects' 66 | * 'date(start,end)' 67 | * 'color' 68 | * 'random(list,of,available,items)' 69 | 70 | :+1: 71 | 72 | אין עוד מלבדו 73 | 74 | [](https://github.com/mooioom/ga-beacon) 75 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stub-objects", 3 | "version": "1.0.0", 4 | "description": "Js stub generator for creating **smart** dummy data", 5 | "main": "stubJs.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/mooioom/stub-js.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/mooioom/stub-js/issues" 17 | }, 18 | "homepage": "https://github.com/mooioom/stub-js#readme" 19 | } 20 | -------------------------------------------------------------------------------- /stubJs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |