Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikeyburkman/x51
Utility for aggregating and flushing items to be processed
https://github.com/mikeyburkman/x51
Last synced: about 5 hours ago
JSON representation
Utility for aggregating and flushing items to be processed
- Host: GitHub
- URL: https://github.com/mikeyburkman/x51
- Owner: MikeyBurkman
- License: mit
- Created: 2016-07-08T00:37:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-22T00:47:51.000Z (over 8 years ago)
- Last Synced: 2024-11-06T19:51:05.385Z (10 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# x51
Utility for aggregating and flushing items to be processed## 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();
```