diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2022-04-20 11:23:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-20 11:23:41 +0300 |
commit | 6afd3fcf653ed92063bafefa83661a076d241585 (patch) | |
tree | 9e1a22ab2f3d3cf1f14ec2348ca0a318fef16898 /doc/api/dns.md | |
parent | 1fe5d56403a3725eac5e67c7a08830ce5ee0e2f5 (diff) |
doc: add `node:` prefix for all core modules
Some core modules can be loaded with or without the `node:` prefix.
Using the prefix disambiguates which specifiers refer to core modules.
This commit updates the docs to use the prefix everywhere a core module
is referenced.
PR-URL: https://github.com/nodejs/node/pull/42752
Fixes: https://github.com/nodejs/node/issues/38343
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'doc/api/dns.md')
-rw-r--r-- | doc/api/dns.md | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/doc/api/dns.md b/doc/api/dns.md index 86f92205c38..c150c8a8abb 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -6,7 +6,7 @@ <!-- source_link=lib/dns.js --> -The `dns` module enables name resolution. For example, use it to look up IP +The `node:dns` module enables name resolution. For example, use it to look up IP addresses of host names. Although named for the [Domain Name System (DNS)][], it does not always use the @@ -16,7 +16,7 @@ communication. To perform name resolution the way other applications on the same system do, use [`dns.lookup()`][]. ```js -const dns = require('dns'); +const dns = require('node:dns'); dns.lookup('example.org', (err, address, family) => { console.log('address: %j family: IPv%s', address, family); @@ -24,14 +24,14 @@ dns.lookup('example.org', (err, address, family) => { // address: "93.184.216.34" family: IPv4 ``` -All other functions in the `dns` module connect to an actual DNS server to +All other functions in the `node:dns` module connect to an actual DNS server to perform name resolution. They will always use the network to perform DNS queries. These functions do not use the same set of configuration files used by [`dns.lookup()`][] (e.g. `/etc/hosts`). Use these functions to always perform DNS queries, bypassing other name-resolution facilities. ```js -const dns = require('dns'); +const dns = require('node:dns'); dns.resolve4('archive.org', (err, addresses) => { if (err) throw err; @@ -65,7 +65,7 @@ the servers used for a resolver using other resolvers: ```js -const { Resolver } = require('dns'); +const { Resolver } = require('node:dns'); const resolver = new Resolver(); resolver.setServers(['4.4.4.4']); @@ -75,7 +75,7 @@ resolver.resolve4('example.org', (err, addresses) => { }); ``` -The following methods from the `dns` module are available: +The following methods from the `node:dns` module are available: * [`resolver.getServers()`][`dns.getServers()`] * [`resolver.resolve()`][`dns.resolve()`] @@ -241,7 +241,7 @@ time to consult the [Implementation considerations section][] before using Example usage: ```js -const dns = require('dns'); +const dns = require('node:dns'); const options = { family: 6, hints: dns.ADDRCONFIG | dns.V4MAPPED, @@ -312,7 +312,7 @@ will be thrown. On an error, `err` is an [`Error`][] object, where `err.code` is the error code. ```js -const dns = require('dns'); +const dns = require('node:dns'); dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { console.log(hostname, service); // Prints: localhost ssh @@ -826,7 +826,7 @@ added: v10.6.0 changes: - version: v15.0.0 pr-url: https://github.com/nodejs/node/pull/32953 - description: Exposed as `require('dns/promises')`. + description: Exposed as `require('node:dns/promises')`. - version: - v11.14.0 - v10.17.0 @@ -836,7 +836,7 @@ changes: The `dns.promises` API provides an alternative set of asynchronous DNS methods that return `Promise` objects rather than using callbacks. The API is accessible -via `require('dns').promises` or `require('dns/promises')`. +via `require('node:dns').promises` or `require('node:dns/promises')`. ### Class: `dnsPromises.Resolver` @@ -852,7 +852,7 @@ the servers used for a resolver using other resolvers: ```js -const { Resolver } = require('dns').promises; +const { Resolver } = require('node:dns').promises; const resolver = new Resolver(); resolver.setServers(['4.4.4.4']); @@ -967,7 +967,7 @@ using `dnsPromises.lookup()`. Example usage: ```js -const dns = require('dns'); +const dns = require('node:dns'); const dnsPromises = dns.promises; const options = { family: 6, @@ -1007,7 +1007,7 @@ On error, the `Promise` is rejected with an [`Error`][] object, where `err.code` is the error code. ```js -const dnsPromises = require('dns').promises; +const dnsPromises = require('node:dns').promises; dnsPromises.lookupService('127.0.0.1', 22).then((result) => { console.log(result.hostname, result.service); // Prints: localhost ssh |