Node.js recursive content spinner algorithm with available predictable behavior.
Based on string-content-spinner (@heek)
npm i content-spinner
Spin a string.
Parameters:
spin(stringToSpin: string[, seed: string]);
const spin = require('content-spinner');
const result = spin('{Hello|Good morning} world');
console.log(result);
This will log either Hello world
or Good morning world
.
const spin = require('content-spinner');
const result = spin('{Hello|Good morning} world', 'Random text');
console.log(result);
This example will always product the same output with the same string passed as the second parameter.
Generates a new spin
function with custom section markers and delimiter.
Parameters:
factory(openSectionMarker: string, closeSectionMarker: string, delimiter: string);
Example:
// Get factory function
const spinFactory = require('content-spinner').factory;
// Generate new spin function with custom section markers and delimiter
const spin = spinFactory('[[', ']]', '::');
// Use it!
const result = spin('Hello [[world::mars]]');
console.log(result);
This will log either Hello world
or Hello mars
.
npm run prettier
: run prettier on source files (both lib and test files)npm run lint
: lint source files (both lib and test files, usingeslint
)npm test
ornpm run test
: run unit testsnpm run git-add
: run prettor, lint and unit tests, if all passed, stage changes