构造 this 的最佳方法是什么.. 返回一个具有多个函数的对象.. 在 this.put 上失败(“this”不再在范围内)..
return {
put: function(o, cb){
fs.writeFile(fn, JSON.stringify(o, null, 4), function(e, r){
if(e) throw e;
cb(o);
})
},
setItem: function(n, v, cb){
this.get(function(o){
o[n] = v;
this.put(o, cb);
})
}