Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrandon Benvie <brandon@bbenvie.com>2012-01-29 08:13:42 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-01-30 03:27:07 +0400
commit5403a8ce4cce83a13569b09ee5b2ba3d1ad8c176 (patch)
treefec6c0c58f9e75ebf4b161d8cfc1fb7626f00192 /src
parente3c0c86b280854e4ad8db9bd5f6c645ffe9e9966 (diff)
core: add `NativeModule.prototype.deprecate`
Formalize and cleanup handling of deprecated core methods.
Diffstat (limited to 'src')
-rw-r--r--src/node.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/node.js b/src/node.js
index 9b3fdad6d96..b924bd1a000 100644
--- a/src/node.js
+++ b/src/node.js
@@ -569,5 +569,25 @@
NativeModule._cache[this.id] = this;
};
+ NativeModule.prototype.deprecate = function(method, message) {
+ var original = this.exports[method];
+ var self = this;
+
+ Object.defineProperty(this.exports, method, {
+ enumerable: false,
+ value: function() {
+ message = self.id + '.' + method + ' is deprecated. ' + (message || '');
+
+ if ((new RegExp('\\b' + self.id + '\\b')).test(process.env.NODE_DEBUG))
+ console.trace(message);
+ else
+ console.error(message);
+
+ self.exports[method] = original;
+ return original.apply(this, arguments);
+ }
+ });
+ };
+
startup();
});