From 2c85dd91d6b1cf76793a8d9c51bd806eb1f36f22 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 12 Dec 2019 23:08:16 +0100 Subject: [PATCH] doc: update REPL documentation to instantiate the REPL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation currently states that it's not intended to directly instantiate REPL instances. It is unknown for what reason that's recommended as it does seem a proper way to handle new REPL instances. PR-URL: https://github.com/nodejs/node/pull/30928 Reviewed-By: Michaƫl Zasso Reviewed-By: Yongsheng Zhang Reviewed-By: Rich Trott Reviewed-By: James M Snell --- doc/api/repl.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index 670705dbf2aa75..8305b1d2c920ca 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -332,10 +332,20 @@ function myWriter(output) { added: v0.1.91 --> +* `options` {Object|string} See [`repl.start()`][] * Extends: {readline.Interface} -Instances of `repl.REPLServer` are created using the `repl.start()` method and -*should not* be created directly using the JavaScript `new` keyword. +Instances of `repl.REPLServer` are created using the [`repl.start()`][] method +or directly using the JavaScript `new` keyword. + +```js +const repl = require('repl'); + +const options = { useColors: true }; + +const firstInstance = repl.start(options); +const secondInstance = new repl.REPLServer(options); +``` ### Event: `'exit'`