Memorized history for generic object.
Can be used in Node.js and browser.
const Loci = require('./Loci');
const data = new Loci(15);
let v = data.get();
let v = data.set(23);
let v = data.undo();
let v = data.redo();
const data = new Loci( { lorem: 15, ipsum: { dolor: 23 }, amet: [1, 2, 3] } );
set <Object>.ipsum.dolor
= 60
data.set(60, 'ipsum', 'dolor');
set <Object>.lorem
= 1 and <Object>.ipsum.dolor
= 2
data.set([
[ 1, 'lorem' ],
[ 2, 'ipsum', 'dolor' ]
]);
In this case, when undo/redo is used, all changes will be undone/redone.
add <Object>.ipsum.tenet
= 20
data.add(20, 'ipsum', 'tenet');
delete <Object>.ipsum.dolor
data.delete('ipsum', 'dolor');
push 4 in <Object>.amet
data.push(4, 'amet');
unshift 4 in <Object>.amet
data.unshift(4, 'amet');
pop from <Object>.amet
data.pop('amet');
shift from <Object>.amet
data.shift('amet');