aboutsummaryrefslogtreecommitdiff
path: root/lib/lorem.js
diff options
context:
space:
mode:
authorMatthew Bergman <[email protected]>2010-05-15 03:10:47 -0400
committerMatthew Bergman <[email protected]>2010-05-15 03:10:47 -0400
commitc6dbabb8689a50754d80693250845efb31c81f68 (patch)
tree0d8efbcc2077b06bb6c214d80742379294875278 /lib/lorem.js
parent1b195d0e13836bcaf82530ccb6f2c89d2744e287 (diff)
downloadfaker-c6dbabb8689a50754d80693250845efb31c81f68.tar.xz
faker-c6dbabb8689a50754d80693250845efb31c81f68.zip
lorem partial working
Diffstat (limited to 'lib/lorem.js')
-rw-r--r--lib/lorem.js45
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/lorem.js b/lib/lorem.js
index f73f7e87..93f7b600 100644
--- a/lib/lorem.js
+++ b/lib/lorem.js
@@ -1,26 +1,26 @@
var Helper = require('../helper');
var definitions = require('../lib/definitions');
-function words(num){
- return Helper.shuffle(lorem);
+exports.words = function(num){
+ if( typeof num == 'undefined'){ var num = 3;}
+ return Helper.shuffle(definitions.lorem).slice(0, num);
//Words.shuffle[0, num]
-}
+};
-function sentence(word_count){
- return 'sentences';
+exports.sentence = function(wordCount){
+ if( typeof wordCount == 'undefined'){ var wordCount = 3;}
+
+ return this.words(wordCount + Helper.randomNumber(7)).join(' ').capitalize();
//words(word_count + rand(6)).join(' ').capitalize + '.'
-}
-
-function sentences(sentence_count){
-
- return 'sentences';
- /*
- returning([]) do |sentences|
- 1.upto(sentence_count) do
- sentences << sentence
- end
- */
-
+};
+
+exports.sentences = function(sentenceCount){
+ if( typeof sentenceCount == 'undefined'){ var sentenceCount = 3;}
+ var sentences = "";
+ for(sentenceCount; sentenceCount >= 0; sentenceCount--){
+ sentences = sentences + this.sentence();
+ }
+ return sentences;
}
function paragraph(sentence_count){
@@ -37,9 +37,8 @@ function paragraphs(paragraph_count){
*/
}
-
-console.log(paragraph());
-console.log(paragraphs());
-console.log(sentence());
-console.log(sentences());
-console.log(words());
+String.prototype.capitalize = function(){ //v1.0
+ return this.replace(/\w+/g, function(a){
+ return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
+ });
+};