diff --git a/.eslintrc.js b/.eslintrc.js index 27dd8aa10c37a1..399c48639f747b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -333,5 +333,6 @@ module.exports = { btoa: 'readable', atob: 'readable', performance: 'readable', + prompt: 'readable' }, }; diff --git a/doc/api/globals.md b/doc/api/globals.md index ea764a20fb30e2..19d7f67740ed82 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -294,6 +294,26 @@ added: v0.1.7 The process object. See the [`process` object][] section. +## `prompt([message[, defaultValue]])` + + + + +* `message` {string} Optional, Message shown to user. Default: `'prompt'`. +* `defaultValue` {string} Optional, Returned value when user inputs the + empty string. +* Returns: {string|null} + +`prompt()` the given message and waits for the user's input. +If the `stdin` is not interactive, it returns `null`. +If default value is not given and the user's input is empty string, it also +returns `null`. +If default value is given and the user's input is empty string, it returns +`defaultValue`. +Otherwise, it returns the user's input as `string`. + ## `queueMicrotask(callback)`