aboutsummaryrefslogtreecommitdiff
path: root/lib/lorem.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/lorem.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/lorem.js')
-rw-r--r--lib/lorem.js57
1 files changed, 55 insertions, 2 deletions
diff --git a/lib/lorem.js b/lib/lorem.js
index 189bbba0..46b5ae22 100644
--- a/lib/lorem.js
+++ b/lib/lorem.js
@@ -1,12 +1,28 @@
+/**
+ *
+ * @namespace faker.lorem
+ */
var Lorem = function (faker) {
var self = this;
var Helpers = faker.helpers;
+ /**
+ * word
+ *
+ * @method faker.lorem.word
+ * @param {number} num
+ */
self.word = function (num) {
return faker.random.arrayElement(faker.definitions.lorem.words);
};
+ /**
+ * generates a space separated list of words
+ *
+ * @method faker.lorem.words
+ * @param {number} num number of words, defaults to 3
+ */
self.words = function (num) {
if (typeof num == 'undefined') { num = 3; }
var words = [];
@@ -16,6 +32,13 @@ var Lorem = function (faker) {
return words.join(' ');
};
+ /**
+ * sentence
+ *
+ * @method faker.lorem.sentence
+ * @param {number} wordCount defaults to a random number between 3 and 10
+ * @param {number} range
+ */
self.sentence = function (wordCount, range) {
if (typeof wordCount == 'undefined') { wordCount = faker.random.number({ min: 3, max: 10 }); }
// if (typeof range == 'undefined') { range = 7; }
@@ -27,6 +50,13 @@ var Lorem = function (faker) {
return sentence.charAt(0).toUpperCase() + sentence.slice(1) + '.';
};
+ /**
+ * sentences
+ *
+ * @method faker.lorem.sentences
+ * @param {number} sentenceCount defautls to a random number between 2 and 6
+ * @param {string} separator defaults to `' '`
+ */
self.sentences = function (sentenceCount, separator) {
if (typeof sentenceCount === 'undefined') { sentenceCount = faker.random.number({ min: 2, max: 6 });}
if (typeof separator == 'undefined') { separator = " "; }
@@ -37,11 +67,24 @@ var Lorem = function (faker) {
return sentences.join(separator);
};
+ /**
+ * paragraph
+ *
+ * @method faker.lorem.paragraph
+ * @param {number} sentenceCount defaults to 3
+ */
self.paragraph = function (sentenceCount) {
if (typeof sentenceCount == 'undefined') { sentenceCount = 3; }
return faker.lorem.sentences(sentenceCount + faker.random.number(3));
};
+ /**
+ * paragraphs
+ *
+ * @method faker.lorem.paragraphs
+ * @param {number} paragraphCount defaults to 3
+ * @param {string} separatora defaults to `'\n \r'`
+ */
self.paragraphs = function (paragraphCount, separator) {
if (typeof separator === "undefined") {
separator = "\n \r";
@@ -54,14 +97,24 @@ var Lorem = function (faker) {
return paragraphs.join(separator);
}
- // returns random text based on a random lorem method
+ /**
+ * returns random text based on a random lorem method
+ *
+ * @method faker.lorem.text
+ * @param {number} times
+ */
self.text = function loremText (times) {
var loremMethods = ['lorem.word', 'lorem.words', 'lorem.sentence', 'lorem.sentences', 'lorem.paragraph', 'lorem.paragraphs', 'lorem.lines'];
var randomLoremMethod = faker.random.arrayElement(loremMethods);
return faker.fake('{{' + randomLoremMethod + '}}');
};
- // returns lines of lorem separated by \n
+ /**
+ * returns lines of lorem separated by `'\n'`
+ *
+ * @method faker.lorem.lines
+ * @param {number} lineCount defaults to a random number between 1 and 5
+ */
self.lines = function lines (lineCount) {
if (typeof lineCount === 'undefined') { lineCount = faker.random.number({ min: 1, max: 5 });}
return faker.lorem.sentences(lineCount, '\n')