Warkanlock / MuteState

A lightweight framework to manipulate state using a queue based structure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MuteState Twitter Node.js CI

A lightweight framework to manipulate state using a queue based structure

How to use it

//Add initial values
Mute.mutate(4);
Mute.mutate(1);
Mute.mutate(2);
Mute.mutate(3);

//Fetch latest or using a step-based latest
console.log(Mute.latest()); // OUTPUT: { lastest: 4 }
console.log(Mute.latestN(1)); // OUTPUT:  { last: 1 }

//You can add objects and manipulate it inside the queue
Mute.mutate({ a: 3 });

//0 is always the latest element added
console.log(Mute.get(0)); // OUTPUT: { value : { a: 3 }}

//And you can fetch all objects instead of just one
console.log(Mute.getAll()); // OUTPUT: { value: [ { a: 3 }, 3, 2, 1, 4 ] }

Demo

Codesandbox Demo

About

A lightweight framework to manipulate state using a queue based structure


Languages

Language:JavaScript 100.0%