diff options
| author | Matthew Bergman <[email protected]> | 2013-01-08 09:35:00 -0800 |
|---|---|---|
| committer | Matthew Bergman <[email protected]> | 2013-01-08 09:35:00 -0800 |
| commit | fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53 (patch) | |
| tree | 28c0bd9453cf4e6d273b97bfe2ce53cab11d3330 /lib/lorem.js | |
| parent | 1e4fcf794181b8d8c9286ee1890a903199f81847 (diff) | |
| parent | 19d0e99ebec18bab6047bf944c07fc472fd9773a (diff) | |
| download | faker-fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53.tar.xz faker-fd79022a8cb6d0d3adc50e8af96a5e2ae93d8e53.zip | |
Merge pull request #37 from BryanDonovan/main
Refactored with 100% test coverage
Diffstat (limited to 'lib/lorem.js')
| -rw-r--r-- | lib/lorem.js | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/lib/lorem.js b/lib/lorem.js index 64b77025..9e1e8e1c 100644 --- a/lib/lorem.js +++ b/lib/lorem.js @@ -1,50 +1,44 @@ +var Faker = require('../index'); var Helpers = require('./helpers'); var definitions = require('../lib/definitions'); -exports.words = function(num) { - if (typeof num == 'undefined') { - num = 3; - } - return Helpers.shuffle(definitions.lorem()).slice(0, num); - //Words.shuffle[0, num] -}; +var lorem = { + words: function (num) { + if (typeof num == 'undefined') { num = 3; } + return Helpers.shuffle(definitions.lorem()).slice(0, num); + }, -exports.sentence = function(wordCount) { - if (typeof wordCount == 'undefined') { - wordCount = 3; - } + sentence: function (wordCount) { + if (typeof wordCount == 'undefined') { wordCount = 3; } - // strange issue with the node_min_test failing for captialize, please fix and add this back - //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize(); + // strange issue with the node_min_test failing for captialize, please fix and add this back + //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize(); - return this.words(wordCount + Helpers.randomNumber(7)).join(' '); -}; + return this.words(wordCount + Faker.random.number(7)).join(' '); + }, -exports.sentences = function(sentenceCount) { - if (typeof sentenceCount == 'undefined') { - sentenceCount = 3; - } - var sentences = []; - for (sentenceCount; sentenceCount >= 0; sentenceCount--) { - sentences.push(this.sentence()); - } - return sentences.join("\n"); -}; + sentences: function (sentenceCount) { + if (typeof sentenceCount == 'undefined') { sentenceCount = 3; } + var sentences = []; + for (sentenceCount; sentenceCount > 0; sentenceCount--) { + sentences.push(this.sentence()); + } + return sentences.join("\n"); + }, -exports.paragraph = function(sentenceCount) { - if (typeof sentenceCount == 'undefined') { - sentenceCount = 3; - } - return this.sentences(sentenceCount + Helpers.randomNumber(3)); -}; + paragraph: function (sentenceCount) { + if (typeof sentenceCount == 'undefined') { sentenceCount = 3; } + return this.sentences(sentenceCount + Faker.random.number(3)); + }, -exports.paragraphs = function(paragraphCount) { - if (typeof paragraphCount == 'undefined') { - paragraphCount = 3; - } - var paragraphs = []; - for (paragraphCount; paragraphCount >= 0; paragraphCount--) { - paragraphs.push(this.paragraph()); - } - return paragraphs.join("\n \r\t"); + paragraphs: function (paragraphCount) { + if (typeof paragraphCount == 'undefined') { paragraphCount = 3; } + var paragraphs = []; + for (paragraphCount; paragraphCount > 0; paragraphCount--) { + paragraphs.push(this.paragraph()); + } + return paragraphs.join("\n \r\t"); + } }; + +module.exports = lorem; |
