Socket
Socket
Sign inDemoInstall

chain-call

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chain-call

Build a chain of method calls


Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
1
Install size
5.24 kB
Created
Weekly downloads
 

Readme

Source

chain-call

Build a chain of method calls

Made with ❤ at @outlandish

npm version js-standard-style

Install

npm install --save chain-call
yarn add chain-call

Import

// ES6
import chainCall from 'chain-call'

// CommonJS
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) // calls api.users().id(59).get().then((response) => response)

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.

Keywords

FAQs

Last updated on 21 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc