npm install enrich-js --save
var obj =name: 'Matt'details:age: 22eyes: 'blue'hair: 'brown';
This can be "enriched" to give it extra functionality:
obj = ;
We can add some handlers for default "change", "undo" and "redo" events, or for custom events. Here we will add handlers for the default events and use the built-in event-to-string functions:
Now we can test them by making some changes and then doing a few undos and redos:
objname = 'Matthew';objdetailsage++;//Console readout://this.name changed from "Matt" to "Matthew"//this.details.age changed from 22 to 23obj; //Note the function chaining//Console readout://this.details.age undone from 23 to 22//this.name undone from "Matthew" to "Matt"//this.name redone from "Matt" to "Matthew"
- 0.1 Initial release