From 84b15ebf2430a0a85e937ba5687c368b4f18091d 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 37ca988cb80..602aea02ab5 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -352,10 +352,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'`