0.0.1 • Published 8 years ago

chainsy v0.0.1

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

chainsy

Function which wraps function definition and gives possibility to chain calls.

examples:

const _ = require('chainsy')

const add = _(function add (first, second) { return first + second }) // named function

const _add = _((first, second) => first + second) // anonymous function

console.log(add(2, 3).add(5).value)
console.log(add(2, 3).add(5).add(10).add(20).value)

console.log('\n')

console.log(_add(2, 3)._(5).value)
console.log(_add(2, 3)._(5)._(10)._(20).value)

or without value, using conversions

console.log(add(5, 3).add(12) + 100) // it behaves like number
console.log(+ add(5, 3).add(12)) // + invokes conversion

or with explicitly specified name

const times = _((x, y) => x * y, 'times')
console.log(+ times(2, 4).times(3).times(9))

Nothing fancy, just small function helper.

0.0.1

8 years ago