mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
doc: fix indentation issues in sample code
In preparation for stricter ESLint indentation checking, fix a few issues in sample code. PR-URL: https://github.com/nodejs/node/pull/13950 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
47d1e125ac
commit
8969c1b762
8 files changed
+108
-104
No files matched your search
+20
-19
@@ -323,21 +323,22 @@ function makeFaster() {
|
||||
});
|
||||
}
|
||||
|
||||
makeFaster(); // will throw:
|
||||
// /home/gbusey/file.js:6
|
||||
// throw new Error('oh no!');
|
||||
// ^
|
||||
// Error: oh no!
|
||||
// at speedy (/home/gbusey/file.js:6:11)
|
||||
// at makeFaster (/home/gbusey/file.js:5:3)
|
||||
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
|
||||
// at Module._compile (module.js:456:26)
|
||||
// at Object.Module._extensions..js (module.js:474:10)
|
||||
// at Module.load (module.js:356:32)
|
||||
// at Function.Module._load (module.js:312:12)
|
||||
// at Function.Module.runMain (module.js:497:10)
|
||||
// at startup (node.js:119:16)
|
||||
// at node.js:906:3
|
||||
makeFaster();
|
||||
// will throw:
|
||||
// /home/gbusey/file.js:6
|
||||
// throw new Error('oh no!');
|
||||
// ^
|
||||
// Error: oh no!
|
||||
// at speedy (/home/gbusey/file.js:6:11)
|
||||
// at makeFaster (/home/gbusey/file.js:5:3)
|
||||
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
|
||||
// at Module._compile (module.js:456:26)
|
||||
// at Object.Module._extensions..js (module.js:474:10)
|
||||
// at Module.load (module.js:356:32)
|
||||
// at Function.Module._load (module.js:312:12)
|
||||
// at Function.Module.runMain (module.js:497:10)
|
||||
// at startup (node.js:119:16)
|
||||
// at node.js:906:3
|
||||
```
|
||||
|
||||
The location information will be one of:
|
||||
@@ -368,7 +369,7 @@ For example:
|
||||
|
||||
```js
|
||||
require('net').connect(-1);
|
||||
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
|
||||
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
|
||||
```
|
||||
|
||||
Node.js will generate and throw `RangeError` instances *immediately* as a form
|
||||
@@ -385,7 +386,7 @@ will do so.
|
||||
|
||||
```js
|
||||
doesNotExist;
|
||||
// throws ReferenceError, doesNotExist is not a variable in this program.
|
||||
// throws ReferenceError, doesNotExist is not a variable in this program.
|
||||
```
|
||||
|
||||
Unless an application is dynamically generating and running code,
|
||||
@@ -419,7 +420,7 @@ string would be considered a TypeError.
|
||||
|
||||
```js
|
||||
require('url').parse(() => { });
|
||||
// throws TypeError, since it expected a string
|
||||
// throws TypeError, since it expected a string
|
||||
```
|
||||
|
||||
Node.js will generate and throw `TypeError` instances *immediately* as a form
|
||||
@@ -709,7 +710,7 @@ const urlSearchParams = new URLSearchParams('foo=bar&baz=new');
|
||||
|
||||
const buf = Buffer.alloc(1);
|
||||
urlSearchParams.has.call(buf, 'foo');
|
||||
// Throws a TypeError with code 'ERR_INVALID_THIS'
|
||||
// Throws a TypeError with code 'ERR_INVALID_THIS'
|
||||
```
|
||||
|
||||
<a id="ERR_INVALID_TUPLE"></a>
|
||||
|
||||
Reference in new issue
Block a user