string-content-spinner

1.0.0 • Public • Published

string-content-spinner

code style: prettier

Node.js recursive content spinner algorithm.

API

spin function

Spin a string.

Parameters:

spin(stringToSpin: string);

Example:

const spin = require('string-content-spinner');
 
const result = spin('{Hello|Good morning} world');
 
console.log(result);

This will log either Hello world or Good morning.

factory function

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('string-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.

Development

Clone repository, then run npm install.

NPM commands

  • npm run prettier: run prettier on source files (both lib and test files)
  • npm run lint: lint source files (both lib and test files, using eslint)
  • npm test or npm run test: run unit tests
  • npm run git-add: run prettor, lint and unit tests, if all passed, stage changes

Readme

Keywords

none

Package Sidebar

Install

npm i string-content-spinner

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • ulflander