aboutsummaryrefslogtreecommitdiff
path: root/lib/helpers.js
diff options
context:
space:
mode:
authorTobias Witt <[email protected]>2016-03-02 15:21:54 +0100
committerMarak <[email protected]>2016-03-03 04:30:38 -0500
commit90a6a04f9cd4a134fec20949e68beb4baf79bfae (patch)
tree70ada7191ace4c22e7d6a5ffa4a65a92d65c92a9 /lib/helpers.js
parent9bb2b7c341bcf41e00341c92a8a66620c401c85f (diff)
downloadfaker-90a6a04f9cd4a134fec20949e68beb4baf79bfae.tar.xz
faker-90a6a04f9cd4a134fec20949e68beb4baf79bfae.zip
Install jsdoc and add doclet stubs for all methods
Descriptions are taken from existing comments if available. The address module already has some new sample descriptions.
Diffstat (limited to 'lib/helpers.js')
-rw-r--r--lib/helpers.js67
1 files changed, 62 insertions, 5 deletions
diff --git a/lib/helpers.js b/lib/helpers.js
index ec8e1573..6434baa3 100644
--- a/lib/helpers.js
+++ b/lib/helpers.js
@@ -1,20 +1,40 @@
+/**
+ *
+ * @namespace faker.helpers
+ */
var Helpers = function (faker) {
var self = this;
- // backword-compatibility
+ /**
+ * backword-compatibility
+ *
+ * @method faker.helpers.randomize
+ * @param {array} array
+ */
self.randomize = function (array) {
array = array || ["a", "b", "c"];
return faker.random.arrayElement(array);
};
- // slugifies string
+ /**
+ * slugifies string
+ *
+ * @method faker.helpers.slugify
+ * @param {string} string
+ */
self.slugify = function (string) {
string = string || "";
return string.replace(/ /g, '-').replace(/[^\w\.\-]+/g, '');
};
- // parses string for a symbol and replace it with a random number from 1-10
+ /**
+ * parses string for a symbol and replace it with a random number from 1-10
+ *
+ * @method faker.helpers.replaceSymbolWithNumber
+ * @param {string} string
+ * @param {string} symbol defaults to `"#"`
+ */
self.replaceSymbolWithNumber = function (string, symbol) {
string = string || "";
// default symbol is '#'
@@ -33,7 +53,12 @@ var Helpers = function (faker) {
return str;
};
- // parses string for symbols (numbers or letters) and replaces them appropriately
+ /**
+ * parses string for symbols (numbers or letters) and replaces them appropriately
+ *
+ * @method faker.helpers.replaceSymbols
+ * @param {string} string
+ */
self.replaceSymbols = function (string) {
string = string || "";
var alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
@@ -51,13 +76,25 @@ var Helpers = function (faker) {
return str;
};
- // takes an array and returns it randomized
+ /**
+ * takes an array and returns it randomized
+ *
+ * @method faker.helpers.shuffle
+ * @param {array} o
+ */
self.shuffle = function (o) {
o = o || ["a", "b", "c"];
for (var j, x, i = o.length-1; i; j = faker.random.number(i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
+ /**
+ * mustache
+ *
+ * @method faker.helpers.mustache
+ * @param {string} str
+ * @param {object} data
+ */
self.mustache = function (str, data) {
if (typeof str === 'undefined') {
return '';
@@ -69,6 +106,11 @@ var Helpers = function (faker) {
return str;
};
+ /**
+ * createCard
+ *
+ * @method faker.helpers.createCard
+ */
self.createCard = function () {
return {
"name": faker.name.findName(),
@@ -119,6 +161,11 @@ var Helpers = function (faker) {
};
};
+ /**
+ * contextualCard
+ *
+ * @method faker.helpers.contextualCard
+ */
self.contextualCard = function () {
var name = faker.name.firstName(),
userName = faker.internet.userName(name);
@@ -149,6 +196,11 @@ var Helpers = function (faker) {
};
+ /**
+ * userCard
+ *
+ * @method faker.helpers.userCard
+ */
self.userCard = function () {
return {
"name": faker.name.findName(),
@@ -174,6 +226,11 @@ var Helpers = function (faker) {
};
};
+ /**
+ * createTransaction
+ *
+ * @method faker.helpers.createTransaction
+ */
self.createTransaction = function(){
return {
"amount" : faker.finance.amount(),