MakeFake
Create data for test, design and other development processes needs data to continue fast.
Table of Contents
Installation
npm install makefake
Example use case
Let's assume you have a design like below and you wanna create ListView for this. But you don't have data currently. You just developing frontend.
let userList = ;
This codes produces an array contain one hundred different user object like that:
;
It's just a simple use case. Let's see Features and Documentation to understand what you can do with this library.
Features
Random data creating
MakeFake can create any primitive and non-primitive data like array or object randomly that contains other primitive or non-primitive data types.
Basic data structure
Define your data structure as same result object.
Custom data formatting
MakeFake allows intervention to editing data during creating.
Documentation
Data types
String
Arguments: _source: array, _charset: string or array, _length: number, _formatter: function(data, content)
let namesArray = "Mahmut" "Brain" "Elizabeth"; // Result (Random): "Mahmut" /* There are couple of predefined data model for _source: makefake.nameSurname: contains name and surname. makefake.username: contains random usernames. makefake.word: contains english words. makefake.language: contains languages. makefake.paragraph: contains paragraphs. makefake.sentence: contain sentences. */ // Result (Random result in makefake.nameSurname array): 'Willie Heppner' // Result (Random): "qwekjaskdj" // You can set _character to 'a-Z', 'A-Z', '0-9', 'Symbol' // You can set _character to custom characters like "abcd1234". // You can set _character to custom char code range like that. // Result (Random): 34512 // Or you can set multiple character sets like that // Result (Random): Z1ctMs // use _formatter to edit produced data // Result (Exactly): @username
Number
Arguments: _max: number, _min: number, _float: boolean, _index: boolean, _formatter: function(data, content)
// Result (Random): 11 // Result (Random): 2019 // Result (Random): 40.39 // Result (Exactly): [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] // Result (Exactly): [ 18, 16, 14, 12, 10, 8, 6, 4, 2, 0 ] /*What is happening here?In 'number' defination _formatter gives a 'content' argumentrepresents number's parent, in this case parent is array,and every array has a 'index' param represents current arrayindex. In 'array' defination _formatter gives a data argumentrepresents array data. We just reversed it.*/
Boolean
Arguments: _truePossibilityPercent: number, _formatter: function (data, content)
_truePossibilityPercent is number between 0 and 100.
// Result (Exactly): true // Result (Exactly): false // Result (Random): true
Array
Arguments: _length: number, _content: object
// Result (Exactly) [ true, false, true, false, true, false, true, false, true, false ]
Object
Arguments: No argument
// create car object // Result (Random) { year: 2014, brand: 'BMW', price: 52737, isExpensive: true }
Color
Arguments: _hue: color, _luminosity: color, _format: string, _alpha: number
See Random Color Documentation
// Result (Random): rgb(163, 162, 242)
Photo
Arguments: _width: color, _height: color
https://picsum.photos/
// Result (Random): https://picsum.photos/500/500/?key=0.47288896556640103&random
License
Copyright 2019 Mahmut Taşkıran
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.