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

Comparing version 0.0.2 to 0.0.3

24

package.json
{
"name": "asca",
"version": "0.0.2",
"author": "Kevin Goslar",
"description": "Convenient parameter binding for asynchronous functions",
"main": "lib/asca.js",
"dependencies": {},
"devDependencies": {

@@ -23,2 +20,12 @@ "chai": "^2.3.0",

"homepage": "https://github.com/Originate/asca",
"keywords": [
"curry",
"async",
"asynchronous",
"parameters",
"binding"
],
"license": "MIT",
"main": "lib/asca.js",
"name": "asca",
"repository": {

@@ -29,8 +36,9 @@ "type": "git",

"scripts": {
"test": "npm run lint && mycha",
"compress": "gulp",
"lint": "find . -name '*.coffee' -not -path './node_modules/*' | xargs coffeelint -f coffeelint.json",
"compress": "gulp"
"postpublish": "git push && git push --tags",
"preversion": "npm test && npm run compress",
"test": "npm run lint && mycha"
},
"author": "Kevin Goslar",
"license": "MIT"
"version": "0.0.3"
}
# Asca
[![Circle CI](https://circleci.com/gh/Originate/asca/tree/master.svg?style=svg)](https://circleci.com/gh/Originate/asca/tree/master)
[![Circle CI](https://circleci.com/gh/Originate/asca/tree/master.svg?style=shield)](https://circleci.com/gh/Originate/asca/tree/master)
Convenient parameter binding for asynchronous functions.
Convenient and readability improving parameter binding
for asynchronous JavaScript functions.
1. load asca
1. load it
```coffeescript

@@ -24,22 +26,23 @@ asca = require 'asca'

3. the `sayHi` method behaves completely normal if called normally,
i.e. given an asynchronous callback
i.e. given all parameters
```coffeescript
sayHi 'world', -> # "Hello world"
sayHi 'world', -> #> "Hello world" & calls the given method when done
```
4. if called without the asynchronous callback,
the `sayHi` method returns a method with all the parameters bound to it.
4. if called without the last parameter (the asynchronous callback),
the `sayHi` method returns a method with all the given parameters bound to it.
This method can be called later by just giving it the callback.
```coffeescript
sayLater = sayHi 'world' # 'sayLater' is a method with the argument
# 'world' bound to it
sayLater -> # "Hello world"
sayWorldLater = sayHi 'world' # 'sayWorldLater' is the sayHi method with
# the argument 'world' bound to it
sayWorldLater -> #> "Hello world" & calls the given method when done
```
5. Use the bound form for very readable asynchronous code constructs,
for example when using [async](https://github.com/caolan/async):
5. This binding allows very readable asynchronous code constructs,
for example when using [async.js](https://github.com/caolan/async):
```coffeescript
# instead of
# instead of this madness
async.parallel [

@@ -50,2 +53,8 @@ (done) -> sayHi 'world', done

# or this mess
async.parallel [
sayHi.bind this, 'world'
sayHi.bind this, 'universe'
]
# we can now say

@@ -58,6 +67,6 @@ async.parallel [

Or other places:
Or in many other places that call a method later
```coffeescript
# instead of
setTimeout ((done) -> sayHi 'world', done), 2000
setTimeout (-> sayHi 'world'), 2000

@@ -68,8 +77,9 @@ # we can now say

All asynchronous JavaScript methods should behave like this.
There are other libraries like [curry](https://www.npmjs.com/package/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.
and might be more appropriate depending on what you want to do.
This library is focussed around delayed asynchrounous function calling,
performs error checking specifically for this use case,
and does that with high performance while being extremely lightweight.

Sorry, the diff of this file is not supported yet

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