1.0.0 • Published 8 years ago

eightyeight v1.0.0

Weekly downloads
1
License
ISC
Repository
gitlab
Last release
8 years ago

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)
);