diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-29 10:17:16 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-29 10:17:16 +0200 |
commit | 93e701f4712ab9e476061f8f81fb03eda1c2af2a (patch) | |
tree | 8e07db9dcb7b44d07d29f2d0a4cd8eccb564302e /lib/api/deprecate.js | |
parent | 68b9bf7e38867eed8763854a731f15959aaf65b5 (diff) | |
download | gitbook-93e701f4712ab9e476061f8f81fb03eda1c2af2a.zip gitbook-93e701f4712ab9e476061f8f81fb03eda1c2af2a.tar.gz gitbook-93e701f4712ab9e476061f8f81fb03eda1c2af2a.tar.bz2 |
Complete deprecated page.progress and this.navigation
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, { |