Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/callback-store
A store for callbacks waiting for delayed response.
https://github.com/zkochan/callback-store
Last synced: 29 days ago
JSON representation
A store for callbacks waiting for delayed response.
- Host: GitHub
- URL: https://github.com/zkochan/callback-store
- Owner: zkochan
- Created: 2015-04-02T20:41:28.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T19:48:07.000Z (about 8 years ago)
- Last Synced: 2024-11-25T06:38:03.558Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# callback-store
A store for callbacks waiting for delayed response.
[![Dependency Status](https://david-dm.org/zkochan/callback-store/status.svg?style=flat)](https://david-dm.org/zkochan/callback-store)
[![Build Status](https://travis-ci.org/zkochan/callback-store.svg?branch=master)](https://travis-ci.org/zkochan/callback-store)
[![npm version](https://badge.fury.io/js/callback-store.svg)](http://badge.fury.io/js/callback-store)
[![Coverage Status](https://coveralls.io/repos/github/zkochan/callback-store/badge.svg?branch=master)](https://coveralls.io/github/zkochan/callback-store?branch=master)## Installation
```
npm install --save callback-store
```## Usage
```js
const cbStore = require('callback-store')let callbacks = cbStore()
let uid = Math.random()
callbacks.add(uid, function(err) {
if (err) {
/* An error will happen if the callback isn't executed during 5 seconds */
return
}
console.log('Hello world!')
}, 5000)/* ... */
let cb = callbacks.get(uid)
cb()
```## License
MIT © [Zoltan Kochan](https://www.kochan.io)