summaryrefslogtreecommitdiffstats
path: root/lib/api/deprecate.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-29 10:17:16 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-29 10:17:16 +0200
commit93e701f4712ab9e476061f8f81fb03eda1c2af2a (patch)
tree8e07db9dcb7b44d07d29f2d0a4cd8eccb564302e /lib/api/deprecate.js
parent68b9bf7e38867eed8763854a731f15959aaf65b5 (diff)
downloadgitbook-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.js23
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, {