diff options
Diffstat (limited to 'node_modules/deprecated/index.js')
-rw-r--r-- | node_modules/deprecated/index.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/node_modules/deprecated/index.js b/node_modules/deprecated/index.js new file mode 100644 index 000000000..f689e9cd1 --- /dev/null +++ b/node_modules/deprecated/index.js @@ -0,0 +1,39 @@ +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;
\ No newline at end of file |