From b3ea8f11920ea03e73e1e46e68ff2bb8bebba17f Mon Sep 17 00:00:00 2001 From: Mestery Date: Tue, 18 Jan 2022 19:04:09 +0100 Subject: [PATCH] doc,readline: add missing node protocol in example PR-URL: https://github.com/nodejs/node/pull/41560 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: James M Snell --- doc/api/readline.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index a6751441010f94..2e081435b9b1ab 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -16,7 +16,20 @@ const readline = require('readline'); The following simple example illustrates the basic use of the `readline` module. -```js +```mjs +import * as readline from 'node:readline/promises'; +import { stdin as input, stdout as output } from 'node:process'; + +const rl = readline.createInterface({ input, output }); + +const answer = await rl.question('What do you think of Node.js? '); + +console.log(`Thank you for your valuable feedback: ${answer}`); + +rl.close(); +``` + +```cjs const readline = require('readline'); const rl = readline.createInterface({