diff options
Diffstat (limited to 'lib/api/deprecate.js')
-rw-r--r-- | lib/api/deprecate.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/api/deprecate.js b/lib/api/deprecate.js index 73ca8be..fd9280f 100644 --- a/lib/api/deprecate.js +++ b/lib/api/deprecate.js @@ -1,3 +1,5 @@ +var is = require('is'); + var logged = {}; var disabled = {}; @@ -40,19 +42,32 @@ function deprecateMethod(book, key, fn, msg) { @param {Book|Output} book @param {String} key: unique identitifer for the deprecated @param {Object} instance - @param {String} property + @param {String|Function} property @param {String} msg: message to print when called @return {Function} */ function deprecateField(book, key, instance, property, value, msg) { + var store = undefined; + + var prepare = function() { + if (!is.undefined(store)) return; + + if (is.fn(value)) store = value(); + else store = value; + } + var getter = function(){ + prepare(); + logNotice(book, key, msg); - return value; + return store; }; var setter = function(v) { + prepare(); + logNotice(book, key, msg); - value = v; - return value; + store = v; + return store; }; Object.defineProperty(instance, property, { |