Socket
Socket
Sign inDemoInstall

asca

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    asca

[![Circle CI](https://circleci.com/gh/Originate/asca/tree/master.svg?style=svg)](https://circleci.com/gh/Originate/asca/tree/master)


Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Asca

Circle CI

Convenient parameter binding for asynchronous functions.

  1. load asca
asca = require 'asca'
  1. define asynchronous functions using asca

sayHi = asca (name, done) ->
  console.log "Hello #{name}"
  done()
  1. the sayHi method behaves completely normal if called normally, i.e. given an asynchronous callback
sayHi 'world', ->   # "Hello world"
  1. if called without the asynchronous callback, the sayHi method returns a method with all the parameters bound to it.
sayLater = sayHi 'world'   # 'sayLater' is a method with the argument
                           # 'world' bound to it
sayLater ->                # "Hello world"
  1. Use the bound form for very readable asynchronous code constructs, for example when using async:
# instead of
async.parallel [
  (done) -> sayHi 'world', done
  (done) -> sayHi 'universe', done
]

# we can now say
async.parallel [
  sayHi 'world'
  sayHi 'universe'
]

Or other places:

# instead of
setTimeout ((done) -> sayHi 'world', done), 2000

# we can now say
setTimeout sayHi('world'), 2000

There are other libraries like curry that provide more comprehensive currying and binding, and might be more appropriate for your intended usage.

This library is focussed around asynchrounous function calling, for example through error checking specifically for that use case. It is also extremely lightweight and performant.

FAQs

Last updated on 25 May 2015

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