forked from Geertvdc/faker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bundled version of Faker.js should now be working
- Loading branch information
Showing
5 changed files
with
139 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
exports.definitions = require('./lib/definitions'); | ||
exports.Name = require('./lib/name'); | ||
exports.Address = require('./lib/address'); | ||
exports.PhoneNumber = require('./lib/phone_number'); | ||
exports.Internet = require('./lib/internet'); | ||
exports.Company = require('./lib/company'); | ||
exports.Lorem = require('./lib/lorem'); | ||
exports.Helpers = require('./lib/helpers'); | ||
|
||
exports.definitions = require('./lib/definitions'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(function (Helpers) { | ||
|
||
// returns a single random number based on a range | ||
Helpers.randomNumber = function(range) { | ||
r = Math.floor(Math.random()*range); | ||
return r; | ||
}; | ||
|
||
// takes an array and returns the array randomly sorted | ||
Helpers.randomize = function(array) { | ||
r = Math.floor(Math.random()*array.length); | ||
return array[r]; | ||
}; | ||
|
||
// parses string for a symbol and replace it with a random number from 1-10 | ||
Helpers.replaceSymbolWithNumber = function(string, symbol){ | ||
|
||
// default symbol is '#' | ||
if(typeof symbol == 'undefined'){ | ||
var symbol = '#'; | ||
} | ||
|
||
var str = ''; | ||
for(var i = 0; i < string.length; i++){ | ||
if(string[i] == symbol){ | ||
str += Math.floor(Math.random()*10); | ||
} | ||
else{ | ||
str += string[i]; | ||
} | ||
} | ||
return str; | ||
}; | ||
|
||
// takes an array and returns it randomized | ||
Helpers.shuffle = function(o){ | ||
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); | ||
return o; | ||
}; | ||
|
||
})( | ||
// exports will be set in any commonjs platform; use it if it's available | ||
typeof exports !== "undefined" ? | ||
exports : | ||
// otherwise construct a name space. outside the anonymous function, | ||
// "this" will always be "window" in a browser, even in strict mode. | ||
this.window = {} | ||
); |