node package manager


Overseer.js A light weight, simple Object.observe shim


Overseer.js A light weight, simple Object.observe shim

Simple : Observe JavaScript Object/Array in simple way;

Small : Only 1.54k after minified!

Use Now :

Unlike native Object.observe , Overseer support FF2.0+ Chrome1.0+ IE8+ Opera9.5+ Safari3+,["age"],function(change){
    //Handle Change here

Include the overseer.js in your project.

<script src="overseer.js"></script>


npm install overseer

var Overseer=require("overseer");

Watch and obj.age

 var obj={name:"wx",age:"24",gen:"male"};,["name","age"],function(change){
        //Handle Change here
   console.log("change ",change.key," from ",change.oldValue," to ",change.newValue);

Then try these:"regou";  // output: "change name from wx to regou"
 obj.age="45";  // output: "change age from 24 to 45";  //output: "regou"
 obj.age;   //output: 45

Watch Array : Watch arr[0] and arr[1]

var arr=["Tom","Jim","Hank"];,[0,1],function(change){
    	//Handle Change here
	 console.log("change ",change.key," from ",change.oldValue," to ",change.newValue);

You can unwatch them if you want:

Overseer.unwatch(obj,["name"]); //unwatch"pop"; // no console output,just change the value

Boolean. if Browser support Overseer,keyArray,callback[,config]);

Observe one or more properties in this Object(shallow watch).

Obj - Object/Array. The Object/Array you want to observe;

keyArray - Array. The keynames/Index of the Object/Array your want to observe,must be array;

callback - Function. Will pass 1 object with 'key','newValue','oldValue','Obj';

config - Object. Do some config in this optional parameter.

config.highPerformance - Boolean. If you do something crazy and the value changing in very high frequency,you should set it to true(may reduce callback times).Default is false.


Observe all properties in this Object/Array (shallow watch).




Unwatch All properties(shallow) in this Object/Array.Also this will restore the Obj/Array to original.