index.js
function paragraph(dict, wordCount, startWithCommon) {
	const result = [];
	let totalWords = 0;
	let words;

	if (startWithCommon && dict.common) {
		words = dict.common.slice(0, wordCount);
		totalWords += words.length;
		result.push(sentence(insertCommas(words), '.'));
	}

	while (totalWords < wordCount) {
		words = sample(dict.words, Math.min(rand(2, 30), wordCount - totalWords));
		totalWords += words.length;
		result.push(sentence(insertCommas(words)));
	}

	return result.join(' ');
}
function paragraph(dict, wordCount, startWithCommon) {
	const result = [];
	let totalWords = 0;
	let words;

	if (startWithCommon && dict.common) {
		words = dict.common.slice(0, wordCount);
		totalWords += words.length;
		result.push(sentence(insertCommas(words), '.'));
	}

	while (totalWords < wordCount) {
		words = sample(dict.words, Math.min(rand(2, 30), wordCount - totalWords));
		totalWords += words.length;
		result.push(sentence(insertCommas(words)));
	}

	return result.join(' ');
}
function paragraph ( dict , wordCount , startWithCommon ) { const result = [ ] ; let totalWords = 0 ; let words ; if ( startWithCommon && dict . common ) { words = dict . common . slice ( 0 , wordCount ) ; totalWords += words . length ; result . push ( sentence ( insertCommas ( words ) , '.' ) ) ; } while ( totalWords < wordCount ) { words = sample ( dict . words , Math . min ( rand ( 2 , 30 ) , wordCount - totalWords ) ) ; totalWords += words . length ; result . push ( sentence ( insertCommas ( words ) ) ) ; } return result . join ( ' ' ) ; }
Generate a paragraph of "Lorem ipsum" text
@param {Object} dict Words dictionary (see `lang/*.json`)
@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