Cutover = function(y_fn, n_fn) {
this.list_ = [];
this.y_fn = y_fn;
this.n_fn = n_fn;
};
Cutover.prototype = {
size : function() {
return this.list_.length;
}, push : function(id, obj) {
var item = {
id : id,
obj : obj
};
this.list_.push(item);
}, on : function(id) {
for ( var idx in this.list_) {
var item = this.list_[idx];
if (item.id == id) this.y_fn.apply(item);
else this.n_fn.apply(item);
}
}, get : function(id){
for ( var idx in this.list_) {
var item = this.list_[idx];
if (item.id == id) return item;
}
}, set : function(id,item){
for ( var idx in this.list_) {
var item = this.list_[idx];
if (item.id == id) this.list_[idx] = item;
}
}
};
自定义的一个JS对象Cutover
最新推荐文章于 2021-06-02 16:49:01 发布