localstorage-fifo-queue
v0.2.0
Published
This package contains a persistant FIFO queue implementation working with localstorage. It can enqueue and dequeue items, as well as peek the next item without deleting it.
Downloads
39
Readme
Storage queue
This package contains a persistant FIFO queue implementation working with localstorage. It can enqueue and dequeue items, as well as peek the next item without deleting it.
Usage
import { LocalStorageQueue } from './src/local-storage-queue';
interface Message {
hello: string;
world: number;
}
const queue = new LocalStorageQueue<Message>('myQueue');
queue.initialize();
queue.enqueue({
hello: '123',
world: 123
});
queue.enqueue({
hello: '456',
world: 456
});
queue.peek();
// { hello: '123', world: 123 } item still in the queue
queue.dequeue();
// { hello: '123', world: 123 } item deleted from queue
queue.dequeue();
// { hello: '456', world: 456 } item deleted from queue
queue.dequeue();
// null queue is empty