eightyeight

Time travel through objects

Usage no npm install needed!

<script type="module">
  import eightyeight from 'https://cdn.skypack.dev/eightyeight';
</script>

README

EightyEight

Time travel through JavaScript Objects.

Installation:

Simply install using npm.

npm install --save eightyeight

Usage


// Let's setup some objects to track. For now, just one.
let trackables = {
    delorean: {
    speed: 88.88
  }
};

// Declare our object.
let EightyEight = require('eightyeight');

// Let EightyEight know what we're tracking.
EightyEight.track(trackables);

// Make a change to the delorean, and a note of the time for example sake.
// EightyEight.now() uses performance.now, or falls back to Date.now()
let someTimeLongAgo = EightyEight.now();
trackables.delorean = Object.assign({}, trackables.delorean, {
    speed: 44.44
});

// Make another change to the delorean, and a note of the time for example sake.
let someTimeSooner = EightyEight.now();
trackables.delorean = Object.assign({}, trackables.delorean, {
    speed: 88.88
});

// So what happened?
console.log(
    `At ${someTimeSooner} the Delorean's state was`,
    EightyEight.to('delorean').at(someTimeSooner)
);

console.log(
    `At ${someTimeLongAgo} the Delorean's state was`,
    EightyEight.to('delorean').at(someTimeLongAgo)
);