savable

0.1.5 • Public • Published

savable

a tool to detect if an object is changed,it can used for smoothly data saving.

install

npm install savable --save

how to use

let wrap = savable({ test: 1 }, function ()
{
    console.log("obj changed")
})
 
wrap.test = 2
wrap.obj = {}
 
console.dir(wrap)       //{ test: 2, obj: {} }
console.log(wrap.__changed)     //true
 
wrap.__changed = false
 
console.log(wrap.__changed) //false
 
wrap.obj.ceshi = "what"
console.log(wrap.__changed) //true
 
wrap.__changed = false
 
console.log(wrap.__changed) //false
 
delete wrap.obj
 
console.dir(wrap)           //{ test: 2 }
console.log(wrap.__changed) //true

Readme

Keywords

Package Sidebar

Install

npm i savable

Weekly Downloads

0

Version

0.1.5

License

MIT

Unpacked Size

7.41 kB

Total Files

7

Last publish

Collaborators

  • bansky