Opal-Estate-Pro/node_modules/deprecated/index.js

39 lines
721 B
JavaScript
Raw Normal View History

2019-09-13 06:27:52 +02:00
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;