You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
721 B
39 lines
721 B
6 years ago
|
var deprecated = {
|
||
|
method: function(msg, log, fn) {
|
||
|
var called = false;
|
||
|
return function(){
|
||
|
if (!called) {
|
||
|
called = true;
|
||
|
log(msg);
|
||
|
}
|
||
|
return fn.apply(this, arguments);
|
||
|
};
|
||
|
},
|
||
|
|
||
|
field: function(msg, log, parent, field, val) {
|
||
|
var called = false;
|
||
|
var getter = function(){
|
||
|
if (!called) {
|
||
|
called = true;
|
||
|
log(msg);
|
||
|
}
|
||
|
return val;
|
||
|
};
|
||
|
var setter = function(v) {
|
||
|
if (!called) {
|
||
|
called = true;
|
||
|
log(msg);
|
||
|
}
|
||
|
val = v;
|
||
|
return v;
|
||
|
};
|
||
|
Object.defineProperty(parent, field, {
|
||
|
get: getter,
|
||
|
set: setter,
|
||
|
enumerable: true
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = deprecated;
|