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/doc
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2016-12-25 21:04:45 +0300
committerJames M Snell <jasnell@gmail.com>2016-12-28 00:16:13 +0300
commit3e4dc60fae7af0cf00c28cc31f3bfdbf58f500e5 (patch)
tree1a6914ef32b5ca2c9d9f65dc477bddb117ed74e3 /doc
parent2b4dfeba1d99c2a89fc26065f81116c46783edce (diff)
doc: more efficient example in the console.md
Object.setPrototypeOf() -> Object.create() PR-URL: https://github.com/nodejs/node/pull/10451 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/console.md23
1 files changed, 14 insertions, 9 deletions
diff --git a/doc/api/console.md b/doc/api/console.md
index 98a05d004f5..70b452bd840 100644
--- a/doc/api/console.md
+++ b/doc/api/console.md
@@ -135,15 +135,20 @@ the default behavior of `console` in Node.js.
// Creates a simple extension of console with a
// new impl for assert without monkey-patching.
-const myConsole = Object.setPrototypeOf({
- assert(assertion, message, ...args) {
- try {
- console.assert(assertion, message, ...args);
- } catch (err) {
- console.error(err.stack);
- }
- }
-}, console);
+const myConsole = Object.create(console, {
+ assert: {
+ value: function assert(assertion, message, ...args) {
+ try {
+ console.assert(assertion, message, ...args);
+ } catch (err) {
+ console.error(err.stack);
+ }
+ },
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ },
+});
module.exports = myConsole;
```