melanke/Watch.JS — pull request #26 by falconair (2012-12-09 06:12:11+00:00)
Title: Adds code to provide 'action' type to all watchers and value arguments to watchers of arrays

Hi,
This code essentially addresses issue 24 https://github.com/melanke/Watch.JS/issues/24).
Now, watchers are passed the following arguments;

object watchers:
(property, action, newvalue, oldvalue)

array watchers:
(property, action, arguments)

``` javascript
For example, given this object:
var ex3 = {
attr1: 0,
attr2: "initial value of attr2",
attr3: ["a", 3, null]
};

watch(ex3, function(arg1, arg2, arg3, arg4,){
console.log("some attribute of ex3 changes:"+arg1+","+arg2+","+arg3+","+arg4);
});

ex3.attr3.push("new value");
ex3.attr2 = "new value";​​
```

Output:
>some attribute of ex3 changes:attr2,set,new value,initial value of attr2
>some attribute of ex3 changes:attr3,push,[object Arguments],undefined

Notice that the action is always "set" for scalar properties and the name of the array function for array properties.