dirtyable.js
dirtyable.js
helps you keep track of changes to properties on objects.
It aims to be a javascript equivalent to ActiveModel::Dirty
Get it.
npm install dirtyable
Track your objects.
dirtyable.extend(object, ['foo', 'bar'])
How to use it
var dirtyable = ; var obj = foo: 'fizzle' bar: 42 baz: 'black sheep';dirtyable; objfoo // => 'fizzle'objfoo_isChanged // => falseobjfoo = 'fo shizzle'objfoo_isChanged // => true
What it does
On the object, it defines the following getters
.isChanged
.changes
.changed
And for each property it extends, it overrides the property with a getter/setter, then adds the following
.<property>_isChanged
.<property>_change
.<property>_was
For more information, check out the annotated source