Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2022-04-20 11:23:41 +0300
committerMichaƫl Zasso <targos@protonmail.com>2022-04-28 07:56:14 +0300
commit3d65a3b13e61f136dc09027aa12473c2b3003725 (patch)
tree012259a22a22fec5325afd386bbae62e3293a09f /doc/api/repl.md
parent46c880b99b4a74c3a7c99fdd824bf9ce22333987 (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/repl.md')
-rw-r--r--doc/api/repl.md38
1 files changed, 19 insertions, 19 deletions
diff --git a/doc/api/repl.md b/doc/api/repl.md
index 4c75bdec2c4..28dc5ecce55 100644
--- a/doc/api/repl.md
+++ b/doc/api/repl.md
@@ -6,17 +6,17 @@
<!-- source_link=lib/repl.js -->
-The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that
-is available both as a standalone program or includible in other applications.
-It can be accessed using:
+The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation
+that is available both as a standalone program or includible in other
+applications. It can be accessed using:
```js
-const repl = require('repl');
+const repl = require('node:repl');
```
## Design and features
-The `repl` module exports the [`repl.REPLServer`][] class. While running,
+The `node:repl` module exports the [`repl.REPLServer`][] class. While running,
instances of [`repl.REPLServer`][] will accept individual lines of user input,
evaluate those according to a user-defined evaluation function, then output the
result. Input and output may be from `stdin` and `stdout`, respectively, or may
@@ -107,7 +107,7 @@ scope. It is possible to expose a variable to the REPL explicitly by assigning
it to the `context` object associated with each `REPLServer`:
```js
-const repl = require('repl');
+const repl = require('node:repl');
const msg = 'message';
repl.start('> ').context.m = msg;
@@ -125,7 +125,7 @@ Context properties are not read-only by default. To specify read-only globals,
context properties must be defined using `Object.defineProperty()`:
```js
-const repl = require('repl');
+const repl = require('node:repl');
const msg = 'message';
const r = repl.start('> ');
@@ -141,7 +141,7 @@ Object.defineProperty(r.context, 'm', {
The default evaluator will automatically load Node.js core modules into the
REPL environment when used. For instance, unless otherwise declared as a
global or scoped variable, the input `fs` will be evaluated on-demand as
-`global.fs = require('fs')`.
+`global.fs = require('node:fs')`.
```console
> fs.createReadStream('./some/file');
@@ -284,7 +284,7 @@ The following illustrates a hypothetical example of a REPL that performs
translation of text from one language to another:
```js
-const repl = require('repl');
+const repl = require('node:repl');
const { Translator } = require('translator');
const myTranslator = new Translator('en', 'fr');
@@ -355,7 +355,7 @@ function for the `writer` option on construction. The following example, for
instance, simply converts any input text to upper case:
```js
-const repl = require('repl');
+const repl = require('node:repl');
const r = repl.start({ prompt: '> ', eval: myEval, writer: myWriter });
@@ -381,7 +381,7 @@ Instances of `repl.REPLServer` are created using the [`repl.start()`][] method
or directly using the JavaScript `new` keyword.
```js
-const repl = require('repl');
+const repl = require('node:repl');
const options = { useColors: true };
@@ -425,7 +425,7 @@ This can be used primarily to re-initialize REPL context to some pre-defined
state:
```js
-const repl = require('repl');
+const repl = require('node:repl');
function initializeContext(context) {
context.m = 'test';
@@ -476,7 +476,7 @@ properties:
The following example shows two new commands added to the REPL instance:
```js
-const repl = require('repl');
+const repl = require('node:repl');
const replServer = repl.start({ prompt: '> ' });
replServer.defineCommand('sayhello', {
@@ -654,7 +654,7 @@ The `repl.start()` method creates and starts a [`repl.REPLServer`][] instance.
If `options` is a string, then it specifies the input prompt:
```js
-const repl = require('repl');
+const repl = require('node:repl');
// a Unix style prompt
repl.start('$ ');
@@ -662,9 +662,9 @@ repl.start('$ ');
## The Node.js REPL
-Node.js itself uses the `repl` module to provide its own interactive interface
-for executing JavaScript. This can be used by executing the Node.js binary
-without passing any arguments (or by passing the `-i` argument):
+Node.js itself uses the `node:repl` module to provide its own interactive
+interface for executing JavaScript. This can be used by executing the Node.js
+binary without passing any arguments (or by passing the `-i` argument):
```console
$ node
@@ -726,8 +726,8 @@ The following example, for instance, provides separate REPLs on `stdin`, a Unix
socket, and a TCP socket:
```js
-const net = require('net');
-const repl = require('repl');
+const net = require('node:net');
+const repl = require('node:repl');
let connections = 0;
repl.start({