sp-analytics-tracker
v0.1.0
Published
Tracker fo sp analytics
Downloads
2
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