faker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jshintignore +3 -0
- package/.jshintrc +87 -0
- package/.npmignore +16 -0
- package/.travis.yml +5 -0
- package/BUILD/BUILD.js +139 -0
- package/BUILD/Mustache.js +296 -0
- package/BUILD/docs.js +62 -0
- package/BUILD/main.js +60 -0
- package/MIT-LICENSE.txt +20 -0
- package/Makefile +26 -0
- package/Readme.md +46 -0
- package/examples/bigDataSet.json +1 -0
- package/examples/browser_test.html +40 -0
- package/examples/dataSet.json +1 -0
- package/examples/index.html +77 -0
- package/examples/js/faker.js +730 -0
- package/examples/js/jquery.js +154 -0
- package/examples/js/prettyPrint.js +712 -0
- package/examples/library_test.js +9 -0
- package/examples/node_generateSet.js +20 -0
- package/examples/node_min_test.js +9 -0
- package/faker.js +730 -0
- package/index.js +31 -0
- package/lib/address.js +100 -0
- package/lib/company.js +36 -0
- package/lib/date.js +42 -0
- package/lib/definitions.js +1398 -0
- package/lib/helpers.js +124 -0
- package/lib/image.js +58 -0
- package/lib/internet.js +53 -0
- package/lib/lorem.js +45 -0
- package/lib/name.js +34 -0
- package/lib/phone_number.js +16 -0
- package/lib/random.js +106 -0
- package/lib/tree.js +69 -0
- package/lib/version.js +0 -0
- package/logo.png +0 -0
- package/minfaker.js +35 -0
- package/package.json +25 -0
- package/test/address.unit.js +293 -0
- package/test/all.functional.js +47 -0
- package/test/browser.unit.html +28 -0
- package/test/company.unit.js +110 -0
- package/test/date.unit.js +65 -0
- package/test/helpers.unit.js +62 -0
- package/test/image.unit.js +108 -0
- package/test/internet.unit.js +92 -0
- package/test/lorem.unit.js +178 -0
- package/test/mocha.opts +5 -0
- package/test/name.unit.js +87 -0
- package/test/phone_number.unit.js +29 -0
- package/test/run.js +68 -0
- package/test/support/chai.js +3403 -0
- package/test/support/sinon-1.5.2.js +4153 -0
- package/test/support/walk_dir.js +43 -0
- package/test/tree.unit.js +108 -0
package/Makefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
BASE = .
|
2
|
+
|
3
|
+
ISTANBUL = ./node_modules/.bin/istanbul
|
4
|
+
COVERAGE_OPTS = --lines 95 --statements 95 --branches 95 --functions 95
|
5
|
+
|
6
|
+
main: lint test
|
7
|
+
|
8
|
+
build:
|
9
|
+
cd BUILD && node BUILD.js
|
10
|
+
|
11
|
+
cover:
|
12
|
+
$(ISTANBUL) cover test/run.js --root ./lib -- -T unit,functional
|
13
|
+
|
14
|
+
check-coverage:
|
15
|
+
$(ISTANBUL) check-coverage $(COVERAGE_OPTS)
|
16
|
+
|
17
|
+
test: cover check-coverage
|
18
|
+
|
19
|
+
test-cov: cover check-coverage
|
20
|
+
open coverage/lcov-report/index.html
|
21
|
+
|
22
|
+
lint:
|
23
|
+
./node_modules/jshint/bin/hint ./lib --config $(BASE)/.jshintrc
|
24
|
+
|
25
|
+
|
26
|
+
.PHONY: test, build
|
package/Readme.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# faker.js - generate massive amounts of fake data in the browser and node.js
|
2
|
+
<img src = "http://imgur.com/KiinQ.png" border = "0">
|
3
|
+
## USAGE
|
4
|
+
### browser -
|
5
|
+
<script src = "faker.js" type = "text/javascript"></script>
|
6
|
+
<script>
|
7
|
+
var randomName = faker.Name.findName(); // Caitlyn Kerluke
|
8
|
+
var randomEmail = faker.Internet.email(); // Rusty@arne.info
|
9
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
10
|
+
</script>
|
11
|
+
### node.js -
|
12
|
+
### usage
|
13
|
+
var faker = require('./faker');
|
14
|
+
var randomName = faker.Name.findName(); // Rowan Nikolaus
|
15
|
+
var randomEmail = faker.Internet.email(); // Kassandra.Haley@erich.biz
|
16
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
17
|
+
## API
|
18
|
+
<ul><li>Name<ul><li>firstName</li><li>firstNameFemale</li><li>firstNameMale</li><li>lastName</li><li>findName</li></ul></li><li>Address<ul><li>zipCode</li><li>zipCodeFormat</li><li>city</li><li>streetName</li><li>streetAddress</li><li>secondaryAddress</li><li>brState</li><li>ukCounty</li><li>ukCountry</li><li>usState</li><li>latitude</li><li>longitude</li></ul></li><li>PhoneNumber<ul><li>phoneNumber</li><li>phoneNumberFormat</li></ul></li><li>Internet<ul><li>email</li><li>userName</li><li>domainName</li><li>domainWord</li><li>ip</li><li>color</li></ul></li><li>Company<ul><li>suffixes</li><li>companyName</li><li>companySuffix</li><li>catchPhrase</li><li>bs</li></ul></li><li>Image<ul><li>avatar</li><li>imageUrl</li><li>abstractImage</li><li>animals</li><li>business</li><li>cats</li><li>city</li><li>food</li><li>nightlife</li><li>fashion</li><li>people</li><li>nature</li><li>sports</li><li>technics</li><li>transport</li></ul></li><li>Lorem<ul><li>words</li><li>sentence</li><li>sentences</li><li>paragraph</li><li>paragraphs</li></ul></li><li>Helpers<ul><li>randomNumber</li><li>randomize</li><li>slugify</li><li>replaceSymbolWithNumber</li><li>shuffle</li><li>createCard</li><li>userCard</li></ul></li><li>Tree<ul><li>clone</li><li>createTree</li></ul></li><li>Date<ul><li>past</li><li>future</li><li>between</li><li>recent</li></ul></li><li>random<ul><li>number</li><li>array_element</li><li>city_prefix</li><li>city_suffix</li><li>street_suffix</li><li>br_state</li><li>br_state_abbr</li><li>us_state</li><li>us_state_abbr</li><li>uk_county</li><li>uk_country</li><li>first_name</li><li>last_name</li><li>name_prefix</li><li>name_suffix</li><li>catch_phrase_adjective</li><li>catch_phrase_descriptor</li><li>catch_phrase_noun</li><li>bs_adjective</li><li>bs_buzz</li><li>bs_noun</li><li>phone_formats</li><li>domain_suffix</li><li>avatar_uri</li></ul></li><li>definitions<ul><li>first_name</li><li>last_name</li><li>name_prefix</li><li>name_suffix</li><li>br_state</li><li>br_state_abbr</li><li>us_state</li><li>us_state_abbr</li><li>city_prefix</li><li>city_suffix</li><li>street_suffix</li><li>uk_county</li><li>uk_country</li><li>catch_phrase_adjective</li><li>catch_phrase_descriptor</li><li>catch_phrase_noun</li><li>bs_adjective</li><li>bs_buzz</li><li>bs_noun</li><li>domain_suffix</li><li>lorem</li><li>phone_formats</li><li>avatar_uri</li></ul></li></ul>
|
19
|
+
## Tests
|
20
|
+
npm install .
|
21
|
+
make test
|
22
|
+
You can view a code coverage report generated in coverage/lcov-report/index.html.
|
23
|
+
## Authors
|
24
|
+
####Matthew Bergman & Marak Squires
|
25
|
+
Heavily inspired by Benjamin Curtis's Ruby Gem [faker](http://faker.rubyforge.org/) and Perl's [Faker](http://search.cpan.org/~awncorp/Faker-0.09/lib/Faker.pm)
|
26
|
+
<br/>
|
27
|
+
Copyright (c) 2014 Matthew Bergman & Marak Squires http://github.com/marak/faker.js/
|
28
|
+
<br/>
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
"Software"), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
<br/>
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
<br/>
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
43
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
44
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
45
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
46
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"name":"Liliana Gibson","username":"Madelyn","email":"Armand@tavares.biz","address":{"street":"Leffler Unions","suite":"Suite 102","city":"Lake Jonatan","zipcode":"60579"},"phone":"(457)497-4068","website":"margarette.uk","company":{"name":"Bruen,Altenwerth and Heathcote","catchPhrase":"Innovative fault-tolerant superstructure","bs":"synergize out-of-the-box partnerships"}},{"name":"Shanie Hauck","username":"Katheryn","email":"Sally@zackery.com","address":{"street":"Balistreri Fields","suite":"Apt. 287","city":"Marafurt","zipcode":"91572"},"phone":"216-402-6789 x1647","website":"hanna.ca","company":{"name":"Abbott-Hermann","catchPhrase":"Extended modular info-mediaries","bs":"evolve granular technologies"}},{"name":"Liliane Fay","username":"Clinton","email":"Josue@dillon.name","address":{"street":"Kihn Road","suite":"Apt. 148","city":"Lenoraborough","zipcode":"19689"},"phone":"1-250-798-0995 x172","website":"francesco.ca","company":{"name":"Luettgen,Wehner and Rolfson","catchPhrase":"Cross-platform discrete structure","bs":"whiteboard dynamic e-tailers"}},{"name":"Thalia Hauck","username":"Chauncey","email":"Jaleel_Bogan@zola.name","address":{"street":"Erdman Divide","suite":"Suite 430","city":"Laurinemouth","zipcode":"77403-6880"},"phone":"1-407-468-7819","website":"samson.name","company":{"name":"Christiansen and Sons","catchPhrase":"Self-enabling methodical open system","bs":"exploit real-time bandwidth"}},{"name":"Breanne Willms","username":"Hobart","email":"Dawn@lynn.info","address":{"street":"O'Conner Summit","suite":"Suite 031","city":"Vivienneview","zipcode":"83910"},"phone":"654-791-5113 x5062","website":"arnoldo.info","company":{"name":"Ferry,Boehm and Bednar","catchPhrase":"Intuitive directional knowledge user","bs":"extend mission-critical experiences"}},{"name":"Regan DuBuque","username":"Elyssa","email":"Faye@royal.ca","address":{"street":"Russel Oval","suite":"Apt. 188","city":"Alexzandermouth","zipcode":"99240"},"phone":"225.773.6392","website":"roxanne.us","company":{"name":"Zulauf-Hammes","catchPhrase":"Cross-group zero administration capability","bs":"expedite front-end architectures"}},{"name":"Antonietta Schinner","username":"Theodora.Medhurst","email":"Reyna.Block@lilly.co.uk","address":{"street":"Abbott Street","suite":"Suite 988","city":"East Fredaville","zipcode":"70477-9430"},"phone":"146-545-1914","website":"weldon.biz","company":{"name":"Cruickshank Group","catchPhrase":"Automated well-modulated circuit","bs":"utilize interactive architectures"}},{"name":"Dr. Lester Russel","username":"Kyla","email":"Amina_Barton@eldridge.co.uk","address":{"street":"Kautzer Court","suite":"Apt. 190","city":"Port Lindseyville","zipcode":"44055-3290"},"phone":"1-556-430-7679","website":"michael.com","company":{"name":"D'Amore and Sons","catchPhrase":"Team-oriented background middleware","bs":"morph granular web services"}},{"name":"Cary Reilly","username":"Marcella.Boehm","email":"Pat@jett.uk","address":{"street":"Flatley Locks","suite":"Suite 779","city":"South Addieland","zipcode":"42791-5340"},"phone":"1-669-561-3826 x52188","website":"bradly.info","company":{"name":"Hilpert-Crona","catchPhrase":"Enterprise-wide transitional capacity","bs":"generate dynamic ROI"}},{"name":"Nettie Smitham","username":"Braden_West","email":"Avis@cortez.biz","address":{"street":"Rippin Trace","suite":"Suite 185","city":"South Domenico","zipcode":"17324-3258"},"phone":"(656)404-9278","website":"adolf.name","company":{"name":"Nikolaus-Bergstrom","catchPhrase":"Switchable background conglomeration","bs":"monetize integrated networks"}},{"name":"Lupe Upton","username":"Eli","email":"Marjory_Howell@stanley.com","address":{"street":"Mueller Spurs","suite":"Suite 348","city":"New Keshawn","zipcode":"07420-7542"},"phone":"752.279.1192 x1924","website":"oral.biz","company":{"name":"Skiles Inc","catchPhrase":"Profit-focused 3rd generation architecture","bs":"maximize cross-media eyeballs"}},{"name":"Emma Weimann","username":"Bret","email":"Abner_Marks@otha.us","address":{"street":"Gorczany Hollow","suite":"Suite 353","city":"Lake Jedidiah","zipcode":"87710-9994"},"phone":"1-895-970-8063 x803","website":"alexa.us","company":{"name":"Hayes-Glover","catchPhrase":"Synchronised maximized moderator","bs":"implement open-source portals"}},{"name":"Aubree Dooley","username":"Joanie_Reilly","email":"Alaina@bennett.ca","address":{"street":"Harris Station","suite":"Apt. 067","city":"East Claudie","zipcode":"36323"},"phone":"262.193.2022","website":"rosalia.us","company":{"name":"Fritsch and Sons","catchPhrase":"Horizontal grid-enabled monitoring","bs":"iterate B2C markets"}},{"name":"Modesto Dibbert","username":"Mohammed.Wintheiser","email":"Leonor@owen.name","address":{"street":"Quitzon Station","suite":"Suite 464","city":"North Johnathanville","zipcode":"69325"},"phone":"725-733-4343 x07214","website":"yvonne.com","company":{"name":"Kris-Lynch","catchPhrase":"Diverse upward-trending success","bs":"whiteboard enterprise e-markets"}},{"name":"Jermey Jacobi","username":"Marjory","email":"Jaclyn@juliana.com","address":{"street":"Casper Knolls","suite":"Suite 861","city":"North Lavernville","zipcode":"15883"},"phone":"1-064-055-1029 x6895","website":"kyle.co.uk","company":{"name":"Howe,Collins and Waters","catchPhrase":"Persistent real-time local area network","bs":"disintermediate distributed infomediaries"}},{"name":"Zachariah Smith","username":"Quincy","email":"Rose.Stiedemann@norma.biz","address":{"street":"Miller Estates","suite":"Apt. 681","city":"New Jared","zipcode":"65557"},"phone":"(269)490-9367","website":"christian.ca","company":{"name":"Bradtke and Sons","catchPhrase":"Compatible impactful Graphic Interface","bs":"unleash interactive interfaces"}},{"name":"Tracey Powlowski","username":"Trisha.Greenholt","email":"Laney@rollin.com","address":{"street":"Lemke Shore","suite":"Suite 151","city":"Patriciashire","zipcode":"09804-1321"},"phone":"1-624-426-5456 x5507","website":"scarlett.biz","company":{"name":"Lockman-Kuvalis","catchPhrase":"Enhanced context-sensitive interface","bs":"enable real-time convergence"}},{"name":"Nickolas Bauch","username":"Romaine","email":"Shania@eli.ca","address":{"street":"Streich Pine","suite":"Apt. 536","city":"New Sammie","zipcode":"60826"},"phone":"466.621.4430 x7410","website":"selina.co.uk","company":{"name":"Howe and Sons","catchPhrase":"Robust analyzing help-desk","bs":"disintermediate real-time convergence"}},{"name":"Kristina Grant","username":"Magnolia_Quigley","email":"Katrine@albertha.us","address":{"street":"Roob Tunnel","suite":"Apt. 630","city":"North Gaylord","zipcode":"52101"},"phone":"(597)488-0874 x21090","website":"chanelle.info","company":{"name":"Gorczany-Will","catchPhrase":"Triple-buffered interactive framework","bs":"maximize front-end models"}},{"name":"Albertha Walter","username":"Freda","email":"Rosie.Kohler@dedrick.biz","address":{"street":"Blanda Grove","suite":"Apt. 724","city":"Port Tyrique","zipcode":"68900"},"phone":"548.845.1835","website":"ottis.uk","company":{"name":"Hayes LLC","catchPhrase":"Innovative global process improvement","bs":"morph enterprise channels"}},{"name":"Alexandria Kovacek","username":"Mittie","email":"Laurine_Heathcote@wendy.com","address":{"street":"Bailey Turnpike","suite":"Suite 729","city":"South Dawnview","zipcode":"47868"},"phone":"382.233.0380 x03245","website":"jarrod.ca","company":{"name":"O'Keefe-Keeling","catchPhrase":"Balanced user-facing collaboration","bs":"enable cross-platform bandwidth"}}]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<script src = "../faker.js" type = "text/javascript"></script>
|
4
|
+
<script>
|
5
|
+
var card = faker.Helpers.createCard();
|
6
|
+
if(typeof JSON == 'undefined'){
|
7
|
+
document.write('get a real browser that has JSON.stringify and JSON.parse built in <br/>');
|
8
|
+
// implement JSON.stringify serialization
|
9
|
+
var JSON = {};
|
10
|
+
JSON.stringify = function (obj) {
|
11
|
+
var t = typeof (obj);
|
12
|
+
if (t != "object" || obj === null) {
|
13
|
+
// simple data type
|
14
|
+
if (t == "string") obj = '"'+obj+'"';
|
15
|
+
return String(obj);
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
// recurse array or object
|
19
|
+
var n, v, json = [], arr = (obj && obj.constructor == Array);
|
20
|
+
for (n in obj) {
|
21
|
+
v = obj[n]; t = typeof(v);
|
22
|
+
if (t == "string") v = '"'+v+'"';
|
23
|
+
else if (t == "object" && v !== null) v = JSON.stringify(v);
|
24
|
+
json.push((arr ? "" : '"' + n + '":') + String(v));
|
25
|
+
}
|
26
|
+
return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
|
27
|
+
}
|
28
|
+
};
|
29
|
+
}
|
30
|
+
document.write(JSON.stringify(card));
|
31
|
+
</script>
|
32
|
+
</head>
|
33
|
+
<body>
|
34
|
+
</body>
|
35
|
+
</html>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"Oswald Goldner","username":"Izaiah","email":"Michael@nicola.us","address":{"street":"Legros Summit","suite":"Suite 061","city":"Lake Jaydeburgh","zipcode":"35411-3193"},"phone":"1-658-413-1550","website":"buddy.ca","company":{"name":"Quigley Group","catchPhrase":"Organized content-based encoding","bs":"generate e-business solutions"}}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>faker.js - generate massive amounts of fake data in Node.js and the browser</title>
|
4
|
+
<script src = "js/jquery.js" type = "text/javascript"></script>
|
5
|
+
<script src = "js/prettyPrint.js" type = "text/javascript"></script>
|
6
|
+
<script src = "js/faker.js" type = "text/javascript"></script>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
|
10
|
+
if(typeof JSON == 'undefined'){
|
11
|
+
document.write('get a real browser that has JSON.stringify and JSON.parse built in <br/>');
|
12
|
+
|
13
|
+
// implement JSON.stringify serialization
|
14
|
+
var JSON = {};
|
15
|
+
JSON.stringify = function (obj) {
|
16
|
+
var t = typeof (obj);
|
17
|
+
if (t != "object" || obj === null) {
|
18
|
+
// simple data type
|
19
|
+
if (t == "string") obj = '"'+obj+'"';
|
20
|
+
return String(obj);
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
// recurse array or object
|
24
|
+
var n, v, json = [], arr = (obj && obj.constructor == Array);
|
25
|
+
for (n in obj) {
|
26
|
+
v = obj[n]; t = typeof(v);
|
27
|
+
if (t == "string") v = '"'+v+'"';
|
28
|
+
else if (t == "object" && v !== null) v = JSON.stringify(v);
|
29
|
+
json.push((arr ? "" : '"' + n + '":') + String(v));
|
30
|
+
}
|
31
|
+
return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
|
32
|
+
}
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
$(document).ready(function(e){
|
37
|
+
|
38
|
+
var card = faker.Helpers.createCard();
|
39
|
+
$('#output').html(prettyPrint(card));
|
40
|
+
|
41
|
+
$('#generate').click(function(){
|
42
|
+
var card = faker.Helpers.createCard();
|
43
|
+
$('#output').html(prettyPrint(card));
|
44
|
+
});
|
45
|
+
|
46
|
+
$('#generateSet').click(function(){
|
47
|
+
|
48
|
+
setTimeout(function(){
|
49
|
+
var cards = [];
|
50
|
+
for(var i = 0; i < $('#cardCount').val(); i++){
|
51
|
+
var card = faker.Helpers.createCard();
|
52
|
+
cards.push(card);
|
53
|
+
}
|
54
|
+
$('#output').html('<textarea cols = "100" rows = "100">'+JSON.stringify(cards)+'</textarea>');
|
55
|
+
}, 10);
|
56
|
+
|
57
|
+
});
|
58
|
+
|
59
|
+
});
|
60
|
+
|
61
|
+
</script>
|
62
|
+
</head>
|
63
|
+
<body>
|
64
|
+
<h1>faker.js - generate massive amounts of fake data in Node.js and the browser</h1>
|
65
|
+
<a href="http://github.com/marak/faker.js/"><img style="position:absolute; z-index:10; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub" /></a>
|
66
|
+
<input id = "generate" type = "button" value = "generate one random card as HTML" />
|
67
|
+
<input id = "generateSet" type = "button" value = "generate an assosative array of random cards as JSON" />
|
68
|
+
card count : <input id = "cardCount" type = "text" size = "3" value = "5" /><br/><br/>
|
69
|
+
<strong>protip</strong>: open your console on this page and run: <code>console.log(faker); var randomName = faker.Name.findName(); console.log(randomName);</code><hr/>
|
70
|
+
<div id = "output"></div>
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|