Node's Pastoral Musicians

    chaino

    0.0.2 • Public • Published

    Chaino 🔗

    Library to create chainable functions.

    Installation

    npm install chaino --save-dev # npm 
    yarn add chaino --save-dev # yarn 

    Usage

    Define your library as chainable list of functions by providing the keys.

    NOTE: Passing non-function keys is fine, but trying to call them will just return the property name.

    // chainable-lib.js
    const chaino = require("chaino");
     
    const keys = {
      red: (str, chain) => `${chain.join(",")} red(${str})`,
      blue: (str, chain) => `${chain.join(",")} blue(${str})`,
      yellow: (str, chain) => `${chain.join(",")} yellow(${str})`,
    }
     
    module.exports = chaino(keys);

    Then your library can be used as:

    // index.js
    const library = require("chainable-lib");
     
    library.red("abc"); // red(abc)
    library.red.blue("abc") // red blue(abc)
    library.blue.yellow.red("abc") // blue,yellow red(abc)

    More examples available here. Initial motivation here.

    License

    MIT

    Install

    npm i chaino

    DownloadsWeekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    101 kB

    Total Files

    10

    Last publish

    Collaborators

    • adityavm