Keg is a messaging queue. It's not suitable for production yet. Expect things to break & change without notice. It includes TypeScript support.
npm i @joduplessis/keg
It's helpful to think in these terms:
- Keg: overall queue ID
- Tap: outlet of messages received, identified by an ID
- Spike: a reduce orientated middleware for messages
- Refill: adds a new message to a keg:tap
- pour(): something like a
next()
to move through the queue
Keg.keg('kegger').tap('demo', async (val, pour) => {
// 'val' is the current value for the demo queue
// We can process it here
// And then move onto the next item in the queue
// Equivalent to next()
pour()
}, () => {
// Tap is empty
})
// Add middleware to each message
Keg.keg('kegger').spike('demo', in => {
return window.btoa(in)
})
Keg.keg('kegger').refill('demo', 'Some text')
Keg.keg('kegger').refill('demo', { order: 'Object message types' })
Keg.keg('kegger').refill('demo', 42)
Any middleware that gets added will act as a pipe. It take the value in
& passes it onto the next spike()
.
- Get base library set up
- Choose a nifty logo
- Add support for multiple kegs
- Add tests
- Package for NPM
- Add support for external pub/subs