Sentence Builder
Build a sentence with variability
let sentence = 'Hello' 'Hi' 'World!' 'Earth!'; sentenceBuilder;// Hi World! sentenceBuilder;// ['Hello World!', 'Hi World!', 'Hello Earth!', 'Hi Earth!']
Installation
- Install the package:
npm install --save sentence-builder
- Require it in your project:
const sentenceBuilder = ;
Usage
build()
Build a sentence:
let sentence = 'Hello' 'Hi' 'World!' 'Earth!'; sentenceBuilder;// Hi World!
All methods take a second parameter, exclude
, which can be given as a single string or an array of strings.
sentenceBuilder;// Hi Earth!
Pass true
as a third parameter to get output as an array.
sentenceBuilder;// ['Hi', 'World!']
combos()
Effectively returns the Cartesian product.
sentenceBuilder;// ['Hello World!', 'Hi World!', 'Hello Earth!', 'Hi Earth!']
Also takes the exclude
parameter.
sentenceBuilder;// ['Hello World!', 'Hi Earth!']
Takes a third parameter, limit
, which limits the results.
sentenceBuilder;// ['Hello World!', 'Hi World!', 'Hello Earth!']
numCombos()
Returns the number of possible combinations.
sentenceBuilder;// 4 sentenceBuilder;// 3