Giter Club home page Giter Club logo

content-spinner's Introduction

content-spinner

code style: prettier

Node.js recursive content spinner algorithm with available predictable behavior.

Based on string-content-spinner (@heek)

Install

npm i content-spinner

API

The spin function

Spin a string.

Parameters:

spin(stringToSpin: string[, seed: string]);

Example without seed parameter:

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.

Example with a seed parameter:

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.

The 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('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

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

content-spinner's People

Contributors

bob6664569 avatar ulflander avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.