SENTENCE GENERATOR
An API of 5 methods which provide granular control over the output of newly generated sentences.
Install
npm install sentence-generator
Initializing
(filepath: string): Object
index.js
const gen = // will resolve to Users/whatevz/project/src/content.txt
src/content.txt
Assume this is the contents of the file resolved at filepath
:
I go to preschool university. We never talk enough about pencil sharpeners. Speak now or forever hold this for one second. It's a collection of paper bags full of plastic bags. This is what I like to think about when I eat dead leaves. Seriously, what's up with all those cookies? My grandmother never owned a rancid juicebar. That is a real homemade sandwich if I've ever seen one. I have to admit that I have never driven this car with my eyes open.
API
take(count: number): String
Returns a string of with a total of count
sentences.
const a = gen console// This is what I like to think about pencil sharpeners. I eat dead leaves. We never owned a rancid juicebar.
run(): String
Returns one sentence leaving any internal state unmutated.
const a = genconst b = gen console// This is what I like to think about pencil sharpeners. I eat dead leaves. We never owned a rancid juicebar. console// We never owned a real homemade sandwich if I've ever seen one second.
generate(): String
Allows the for the creation of a sequence in a manner similar to a for loop. Each call returns the current state of accumulation.
const a = genconst c = gen console// This is what I like to think about pencil sharpeners. I eat dead leaves. We never owned a rancid juicebar. console// This is what I like to think about pencil sharpeners. I eat dead leaves. We never owned a rancid juicebar. Speak now or forever hold this car with all those cookies?
clear(): Void
Resets any internal state persisted from previous method calls (such as generate
or take
). Useful with recursion an edge condition is met.
const gen = { const value = gen if valuelength > 140 genclear return else if valuelength > 100 return else return } // Starts over if the number of characters in// the string exceeds 140 and finishes only // when the accumulated string contains a number// of characters greater than 100 and less than 140
unwrap(): String
Returns the current persisted state.
gengengengen // equivalent to calling `gen.take(4)` const result = gen/* Returns a string of four sentences */