summaryrefslogtreecommitdiff
path: root/doc/api/url.md
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-06-01 01:21:22 +0300
committerVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-06-03 01:33:55 +0300
commit7de6998d899125e9d43de7dae0bb0a0ed9a76d34 (patch)
tree73f0c31fe41024a56ea06910d01c5a0714b334b0 /doc/api/url.md
parent78b135806f10c39c3bbd00edf206ddc9f505597e (diff)
downloadandroid-node-v8-7de6998d899125e9d43de7dae0bb0a0ed9a76d34.tar.gz
android-node-v8-7de6998d899125e9d43de7dae0bb0a0ed9a76d34.tar.bz2
android-node-v8-7de6998d899125e9d43de7dae0bb0a0ed9a76d34.zip
doc: use destructuring in code examples
PR-URL: https://github.com/nodejs/node/pull/13349 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/url.md')
-rw-r--r--doc/api/url.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/api/url.md b/doc/api/url.md
index a74ca26e08..837e41e8ff 100644
--- a/doc/api/url.md
+++ b/doc/api/url.md
@@ -55,7 +55,7 @@ properties of a WHATWG `URL` object.
Parsing the URL string using the WHATWG API:
```js
-const URL = require('url').URL;
+const { URL } = require('url');
const myURL =
new URL('https://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash');
```
@@ -607,7 +607,7 @@ Alias for [`urlSearchParams[@@iterator]()`][`urlSearchParams@@iterator()`].
Iterates over each name-value pair in the query and invokes the given function.
```js
-const URL = require('url').URL;
+const { URL } = require('url');
const myURL = new URL('https://example.org/?a=b&c=d');
myURL.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURL.searchParams === searchParams);
@@ -1098,7 +1098,7 @@ using the [Punycode][] algorithm. Note, however, that a hostname *may* contain
*both* Punycode encoded and percent-encoded characters. For example:
```js
-const URL = require('url').URL;
+const { URL } = require('url');
const myURL = new URL('https://%CF%80.com/foo');
console.log(myURL.href);
// Prints https://xn--1xa.com/foo