Comparing version 0.0.1 to 0.1.0
{ | ||
"name" : "batchify", | ||
"version" : "0.0.1", | ||
"main" : "./lib/batchify.coffee", | ||
"description" : "", | ||
"dependencies" :{ | ||
"coffee-script": ">=1.2.0" | ||
"name": "batchify", | ||
"version": "0.1.0", | ||
"main": "./lib/batchify.js", | ||
"description": "", | ||
"dependencies": { | ||
}, | ||
"devDependencies" : | ||
{ | ||
"mocha" : ">=0.13.0", | ||
"should" : ">=0.5.1" | ||
"devDependencies": { | ||
"gulp": "~3.6.0", | ||
"gulp-mocha": "~0.4.1", | ||
"should": "~3.2.0", | ||
"mocha": "~1.18.2" | ||
}, | ||
"engines" : | ||
{ | ||
"node" : ">=0.6.10" | ||
"engines": { | ||
"node": ">=0.6.10" | ||
}, | ||
"scripts" : | ||
{ | ||
"test" : "bin/run_tests" | ||
"scripts": { | ||
"test": "gulp" | ||
} | ||
} |
@@ -0,10 +1,12 @@ | ||
[](https://travis-ci.org/davidmfoley/batchify) | ||
# Batchify | ||
Batches calls to a particular resource (such as a database or network) so that, rather than making the call multiple times, a single call is made and all callbacks are triggered when it completes. | ||
In some situations, many identical operations can occur in a short period of time, causing performance issues. | ||
For example, let's say that we have the following code: | ||
Batchify wraps a function so that when it is invoked with identical arguments multiple times while in progress, it will only be invoked once, and all callbacks will be notified when it completes. | ||
```coffee | ||
users.findAll (users) -> | ||
```javascript | ||
users.findAll(function(err, users) { | ||
# do something with each user | ||
}); | ||
``` | ||
@@ -15,7 +17,7 @@ | ||
With batchify, one request will be used to service all of the concurrent requests: | ||
```coffee | ||
batchedFindAll = Batchify.wrap(users, 'findAll') | ||
```javascript | ||
var batchedFindAll = Batchify.wrap(users, 'findAll'); | ||
# Now you use batchedFindAll the same as you would the original function: | ||
batchedFindAll (users) -> | ||
batchedFindAll(function(err, users) { ... }); | ||
``` | ||
@@ -25,11 +27,5 @@ | ||
The wrapped function can have parameters too: | ||
The wrapped function can have parameters too. | ||
```coffee | ||
batchedFindByState = Batchify.wrap(users, 'findByState') | ||
batchedFindAll 'active', (users) -> | ||
``` | ||
(Batchify uses the parameter values as a hash key, so concurrent calls with different parameters will not conflict) | ||
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
5602
0
8
145
0
4
30
- Removedcoffee-script@>=1.2.0
- Removedcoffee-script@1.12.7(transitive)