1.0.2 • Published 4 years ago

chain-caller v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

chain-caller

Used to create objects similar to colors, which can be chained to call methods, and finally process parameters

Examle

import chaincaller from 'chain-caller';

const colors = chaincaller(['red', 'blue', 'yellow', 'bold', 'italic'], function(str) {
    return `<div class="${this.chain.join(' ')}">${str}</div>`
})

var str = colors.red.bold.italic('hello world');

console.log(str)

// <div class="red bold italic">hello world</div>

Explain

const obj = chaincaller(list, callback)

list

The collection of method names in the call chain, in fact, the callback function is executed when the final method is called, and the final called collection is passed to the callback function through this.chain.

callback

Because callback requires "this" to be passed, arrow functions cannot be used

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago