chain-call
Build a chain of method calls
Made with ❤ at @outlandish
Install
npm install --save chain-call
yarn add chain-call
Import
import chainCall from 'chain-call'
var chainCall = require('chain-call')
Example
const callApi = (entity, identifier) => chainCall(api, [
entity,
[typeof identifier === 'string' ? 'slug' : 'id', identifier],
'get',
['then', (response) => response]
])
callApi('users', 59)
API
chainCall(subject, calls)
Chain call methods on an object.
- subject {Object} Object to chain method calls on
- calls {Array} Array of calls to chain
Returns the result of invoking each method in calls
one-by-one
on the return of the previous, beginning with a call on subject
.
Contributing
All pull requests and issues welcome!
If you're not sure how, check out Kent C. Dodds'
great video tutorials on egghead.io!
Author & License
chain-call
was created by Sam Gluck and is released under the MIT license.