Skip to content

terite/dirtyable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status #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 = require('dirtyable');

var obj = {
    foo: 'fizzle',
    bar: 42,
    baz: 'black sheep'
};
dirtyable.extend(obj, ['foo', 'bar']);

obj.foo // => 'fizzle'
obj.foo_isChanged // => false
obj.foo = 'fo shizzle'
obj.foo_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

About

Keep track of object property changes in Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published