From 7de6998d899125e9d43de7dae0bb0a0ed9a76d34 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Thu, 1 Jun 2017 01:21:22 +0300 Subject: doc: use destructuring in code examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/13349 Reviewed-By: Anna Henningsen Reviewed-By: Yuta Hiroto Reviewed-By: Timothy Gu Reviewed-By: Daijiro Wachi Reviewed-By: Luigi Pinca Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Tobias Nießen Reviewed-By: James M Snell --- doc/api/url.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc/api/url.md') 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 -- cgit v1.2.3