-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87707ea
commit d0aa774
Showing
5 changed files
with
99 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"globals": { | ||
"it": true, | ||
"describe": true, | ||
"beforeEach": true | ||
}, | ||
"curly": true, | ||
"camelcase": false, | ||
"evil": false, | ||
"expr": true, | ||
"browser": true, | ||
"trailing": true, | ||
"sub": true, | ||
"eqeqeq": false, | ||
"eqnull": true, | ||
"devel": false, | ||
"smarttabs": false, | ||
"laxbreak": false, | ||
"laxcomma": true, | ||
"jquery": false, | ||
"loopfunc": true, | ||
"indent": 2, | ||
"bitwise": true, | ||
"noarg": true, | ||
"noempty": true, | ||
"nonew": true, | ||
"undef": true, | ||
"boss": true, | ||
"node": true, | ||
"newcap": true, | ||
"quotmark": "single", | ||
"unused": true, | ||
"strict": true, | ||
"maxparams": 6, | ||
"maxdepth": 5, | ||
"maxstatements": 20, | ||
"maxcomplexity": 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
# x51 | ||
Utility for aggregating and flushing items to be processed | ||
|
||
### TODO More documentation | ||
## When do I use this? | ||
Use this when you want to collect items, and flush them out to another function | ||
when either you have enough items, or when enough time has passed. | ||
|
||
## How do I use it? | ||
```js | ||
// require('x51') returns a function to initialize a new x51 instance | ||
var x51 = require('x51')({ | ||
flushInterval: 60000, // Milliseconds between flushing, defaults to 60,000 | ||
maxRecords: Infinity, // Max items to collect before flushing, defaults to Infinity | ||
flush: function(items) { | ||
// Receives a non-empty array of items to be flushed. | ||
// If this function throws an error, or returns a promise that is rejected, | ||
// then these items are automatically kept, and will be flushed again next time. | ||
console.log('Items: ', items); | ||
} | ||
}); | ||
|
||
x51.push('item1'); | ||
x51.push({ | ||
foo: 'Items can be anything' | ||
}); | ||
|
||
// If you feel the need, you can also manually flush at any time... | ||
x51.flush(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters