This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: add
NativeModule.prototype.deprecate
Formalize and cleanup handling of deprecated core methods.
- Loading branch information
1 parent
e3c0c86
commit 5403a8c
Showing
5 changed files
with
32 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tim-smart
|
||
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(); | ||
}); |
Just a concern after taking a glance of this. If you did:
Wouldn't you get the warning twice?