rocker_ipsum
v0.0.8
Published
Generate rocking text instead of lorem ipsum.
Downloads
15
Readme
Rocker Ipsum
A small library that generate rocking text rather than boring lorem ipsum.
Installation
npm install rocker_ipsum
or
yarn install rocker_ipsum
API
RockerIpsum is a function that generates rockin' text for mockups, wireframes, or dummy text wherever you need it.
ES6 +
import { rockerIpsum } from 'rocker_ipsum';
const ipsumText = rockerIpsum(2, 5, 50, 70, true, 6);
ES5 +
var rockerIpsum = require('rocker_ipsum').rockerIpsum;
var ipsumText = rockerIpsum(2, 5, 50, 70, true, 6);
The function will return an array containing one or more objects with rocker ipsum text. See configuration options below.
Options
The main function, rockerIpsum()
accepts six parameters, as detailed here:
rockerIpsum(paragraphs, sentences, minWords, maxWords, createTitle, titleMaxLength)
paragraphs integer
The paragraphs parameter allows you to specify how many paragraphs you would like to generate. By default, a single paragraph will be generated.
sentences integer
The paragraphs parameter allows you to specify how many lines of text each paragraph should contain. By default, each paragraph contains five sentences.
minWords integer
The minWords parameter allows you to specify a minimum number of words that each paragraph should contain. By default, each paragraph must contain at least 50 words.
maxWords integer
The maxWords parameter allows you to specify a maximum number of words that each paragraph should contain. By default, there is no maximum number of words per paragraph.
createTitle boolean
The createTitle parameter allows you to create titles in addition to paragraphs. If you pass true
as the argument for this parameter, the output will include both title and text. The createTitle parameter is set to false by default.
maxTitleLength integer
The maxTitleLength parameter allows you to specify a maximum number of words that each title should contain. Titles are typically between 5 and 10 words. By default, no maxTitleLength is set. The createTitle
variable must be set to true to specify maxTitleLength. Titles can be no longer than 10 words. If you specify a value larger than 10, only 10 words will be returned.
Usage
Generate Rocker Ipsum object by calling the following function:
const generatedText = rockerIpsum(2, 4, 50, 80, true, false);
The resulting generatedText
variable should contain an array with two distinct objects, each containing at text
field with least four lines of text with a total length between 50 and 80 characters and a title
field.
Using Default Values
You do not need to provide arguments if you would like to use only default values (as described above). However, if you would like to customize the function's output, specify arguments that you would like to use and pass null
arguments for any of the parameters that you don't care to specify, such as:
const generatedText = rockerIpsum(null, 4, null, 80, true, 5);
Make sure to pass null
arguments to any of the parameters that you don't wish to specify.
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.