Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gfellerph/flux-capacitor
A time machine for JS objects
https://github.com/gfellerph/flux-capacitor
Last synced: about 2 months ago
JSON representation
A time machine for JS objects
- Host: GitHub
- URL: https://github.com/gfellerph/flux-capacitor
- Owner: gfellerph
- License: mit
- Created: 2016-01-04T16:13:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-04T16:40:48.000Z (about 9 years ago)
- Last Synced: 2024-10-15T02:06:48.242Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flux-capacitor
A time machine for JS objects```
npm install --save mxm-flux-capacitor
```
...
```javascript
var FluxCapacitor = require('mxm-flux-capacitor');
var capacitor = new FluxCapacitor();var obj = {some:'object'};
// Push the current state of obj to the capacitor
capacitor.charge(obj);// Alter obj
obj.some = 'thing else';// Push again
capacitor.charge(obj);
console.log(capacitor.charger); // [{some: 'object'}, {some: 'thing else'}]// Revert to first state
obj = capacitor.back();
// or
obj = capacitor.jump(0);
console.log(obj); // {some: 'object'}// Go forward again
obj = capacitor.forward();
// or
obj = capacitor.jump(capacitor.charger.length -1);
console.log(obj); // {some: 'thing else'}// Get current year (index)
var current = capacitor.year; // Default: -1, no charges// Set max number of objects to remember
capacitor.maxOverload = 20; // Default: 10// Reset capacitor (delete all states)
capacitor.supercharge();
```