diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2022-04-20 11:23:41 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2022-04-28 07:56:14 +0300 |
commit | 3d65a3b13e61f136dc09027aa12473c2b3003725 (patch) | |
tree | 012259a22a22fec5325afd386bbae62e3293a09f /doc/api/v8.md | |
parent | 46c880b99b4a74c3a7c99fdd824bf9ce22333987 (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/v8.md')
-rw-r--r-- | doc/api/v8.md | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/doc/api/v8.md b/doc/api/v8.md index 2689b6813fe..2126a0bd5e6 100644 --- a/doc/api/v8.md +++ b/doc/api/v8.md @@ -4,11 +4,11 @@ <!-- source_link=lib/v8.js --> -The `v8` module exposes APIs that are specific to the version of [V8][] +The `node:v8` module exposes APIs that are specific to the version of [V8][] built into the Node.js binary. It can be accessed using: ```js -const v8 = require('v8'); +const v8 = require('node:v8'); ``` ## `v8.cachedDataVersionTag()` @@ -80,7 +80,7 @@ for a duration depending on the heap size. ```js // Print heap snapshot to the console -const v8 = require('v8'); +const v8 = require('node:v8'); const stream = v8.getHeapSnapshot(); stream.pipe(process.stdout); ``` @@ -233,7 +233,7 @@ Usage: ```js // Print GC events to stdout for one minute. -const v8 = require('v8'); +const v8 = require('node:v8'); v8.setFlagsFromString('--trace_gc'); setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3); ``` @@ -308,12 +308,12 @@ Generating a snapshot is a synchronous operation which blocks the event loop for a duration depending on the heap size. ```js -const { writeHeapSnapshot } = require('v8'); +const { writeHeapSnapshot } = require('node:v8'); const { Worker, isMainThread, parentPort -} = require('worker_threads'); +} = require('node:worker_threads'); if (isMainThread) { const worker = new Worker(__filename); @@ -593,7 +593,7 @@ module to produce promise lifecycle events in addition to events for other async resources. For request context management, see [`AsyncLocalStorage`][]. ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; // There are four lifecycle events produced by promises: @@ -662,13 +662,13 @@ added: throw as it would produce an infinite microtask loop.** ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; const stop = promiseHooks.onInit((promise, parent) => {}); ``` ```cjs -const { promiseHooks } = require('v8'); +const { promiseHooks } = require('node:v8'); const stop = promiseHooks.onInit((promise, parent) => {}); ``` @@ -689,13 +689,13 @@ added: throw as it would produce an infinite microtask loop.** ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; const stop = promiseHooks.onSettled((promise) => {}); ``` ```cjs -const { promiseHooks } = require('v8'); +const { promiseHooks } = require('node:v8'); const stop = promiseHooks.onSettled((promise) => {}); ``` @@ -716,13 +716,13 @@ added: throw as it would produce an infinite microtask loop.** ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; const stop = promiseHooks.onBefore((promise) => {}); ``` ```cjs -const { promiseHooks } = require('v8'); +const { promiseHooks } = require('node:v8'); const stop = promiseHooks.onBefore((promise) => {}); ``` @@ -743,13 +743,13 @@ added: throw as it would produce an infinite microtask loop.** ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; const stop = promiseHooks.onAfter((promise) => {}); ``` ```cjs -const { promiseHooks } = require('v8'); +const { promiseHooks } = require('node:v8'); const stop = promiseHooks.onAfter((promise) => {}); ``` @@ -783,7 +783,7 @@ specifics of all functions that can be passed to `callbacks` is in the [Hook Callbacks][] section. ```mjs -import { promiseHooks } from 'v8'; +import { promiseHooks } from 'node:v8'; const stopAll = promiseHooks.createHook({ init(promise, parent) {} @@ -791,7 +791,7 @@ const stopAll = promiseHooks.createHook({ ``` ```cjs -const { promiseHooks } = require('v8'); +const { promiseHooks } = require('node:v8'); const stopAll = promiseHooks.createHook({ init(promise, parent) {} |