lib/generator/lorem.js
function paragraph(lang, wordCount, startWithCommon) {
		var data = langs[lang];
		if (!data) {
			return '';
		}

		var result = [];
		var totalWords = 0;
		var words;
		
		wordCount = parseInt(wordCount, 10);
		
		if (startWithCommon && data.common) {
			words = data.common.slice(0, wordCount);
			if (words.length > 5) {
				words[4] += ',';
			}
			totalWords += words.length;
			result.push(sentence(words, '.'));
		}
		
		while (totalWords < wordCount) {
			words = sample(data.words, Math.min(randint(2, 30), wordCount - totalWords));
			totalWords += words.length;
			insertCommas(words);
			result.push(sentence(words));
		}
		
		return result.join(' ');
	}
function paragraph(lang, wordCount, startWithCommon) {
		var data = langs[lang];
		if (!data) {
			return '';
		}

		var result = [];
		var totalWords = 0;
		var words;
		
		wordCount = parseInt(wordCount, 10);
		
		if (startWithCommon && data.common) {
			words = data.common.slice(0, wordCount);
			if (words.length > 5) {
				words[4] += ',';
			}
			totalWords += words.length;
			result.push(sentence(words, '.'));
		}
		
		while (totalWords < wordCount) {
			words = sample(data.words, Math.min(randint(2, 30), wordCount - totalWords));
			totalWords += words.length;
			insertCommas(words);
			result.push(sentence(words));
		}
		
		return result.join(' ');
	}
function paragraph ( lang , wordCount , startWithCommon ) { var data = langs [ lang ] ; if ( ! data ) { return '' ; } var result = [ ] ; var totalWords = 0 ; var words ; wordCount = parseInt ( wordCount , 10 ) ; if ( startWithCommon && data . common ) { words = data . common . slice ( 0 , wordCount ) ; if ( words . length > 5 ) { words [ 4 ] += ',' ; } totalWords += words . length ; result . push ( sentence ( words , '.' ) ) ; } while ( totalWords < wordCount ) { words = sample ( data . words , Math . min ( randint ( 2 , 30 ) , wordCount - totalWords ) ) ; totalWords += words . length ; insertCommas ( words ) ; result . push ( sentence ( words ) ) ; } return result . join ( ' ' ) ; }
Generate a paragraph of "Lorem ipsum" text
@param {Number} wordCount Words count in paragraph
@param {Boolean} startWithCommon Should paragraph start with common
"lorem ipsum" sentence.
@returns {String}
Generate a paragraph of Lorem ipsum text