Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: sort documentation alphabetically #3662

Closed
wants to merge 32 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ecd2179
doc: sort assert alphabetically
tflanagan Nov 4, 2015
63a2e55
doc: sort buffer alphabetically
tflanagan Nov 4, 2015
7b4f78a
doc: sort child_process alphabetically
tflanagan Nov 4, 2015
e650680
doc: sort cluster alphabetically
tflanagan Nov 4, 2015
cfed942
doc: sort console alphabetically
tflanagan Nov 4, 2015
03dd92c
doc: sort dns alphabetically
tflanagan Nov 4, 2015
d9e5b6a
doc: sort crypto alphabetically
tflanagan Nov 4, 2015
43f2da0
doc: sort dgram alphabetically
tflanagan Nov 4, 2015
b85d3ac
doc: sort errors alphabetically
tflanagan Nov 4, 2015
03129f8
doc: sort events alphabetically
tflanagan Nov 4, 2015
c44523a
doc: sort fs alphabetically
tflanagan Nov 4, 2015
0c181d1
doc: sort globals alphabetically
tflanagan Nov 4, 2015
99c8160
doc: sort os alphabetically
tflanagan Nov 4, 2015
820506e
doc: sort path alphabetically
tflanagan Nov 4, 2015
33a6975
doc: sort punycode alphabetically
tflanagan Nov 4, 2015
5c37462
doc: sort querystring alphabetically
tflanagan Nov 4, 2015
ac62941
doc: sort vm alphabetically
tflanagan Nov 4, 2015
8c83054
doc: sort url alphabetically
tflanagan Nov 4, 2015
cc6f224
doc: sort tty alphabetically
tflanagan Nov 4, 2015
15a8370
doc: sort timers alphabetically
tflanagan Nov 4, 2015
da7afdc
doc: sort string_decoder alphabetically
tflanagan Nov 4, 2015
059c98a
doc: sort repl alphabetically
tflanagan Nov 4, 2015
7ccad23
doc: sort readline alphabetically
tflanagan Nov 4, 2015
89122ce
doc: sort modules alphabetically
tflanagan Nov 4, 2015
3595327
doc: sort http alphabetically
tflanagan Nov 4, 2015
bed67d2
doc: sort https alphabetically
tflanagan Nov 4, 2015
5b09a1c
doc: sort util alphabetically
tflanagan Nov 5, 2015
37d037b
doc: sort zlib alphabetically
tflanagan Nov 5, 2015
8dbd518
doc: sort process alphabetically
tflanagan Nov 5, 2015
9811315
doc: sort net alphabetically
tflanagan Nov 5, 2015
e8c1e06
doc: sort stream alphabetically
tflanagan Nov 5, 2015
1b86f37
doc: sort tls alphabetically
tflanagan Nov 5, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: sort readline alphabetically
Reorders, with no contextual changes, the readline documentation
alphabetically.
  • Loading branch information
tflanagan committed Nov 5, 2015
commit 7ccad23156aa60d20371d8f88d5a39e21969bc18
211 changes: 105 additions & 106 deletions doc/api/readline.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,75 +23,21 @@ program to gracefully exit:
rl.close();
});

## readline.createInterface(options)

Creates a readline `Interface` instance. Accepts an "options" Object that takes
the following values:

- `input` - the readable stream to listen to (Required).

- `output` - the writable stream to write readline data to (Optional).

- `completer` - an optional function that is used for Tab autocompletion. See
below for an example of using this.

- `terminal` - pass `true` if the `input` and `output` streams should be
treated like a TTY, and have ANSI/VT100 escape codes written to it.
Defaults to checking `isTTY` on the `output` stream upon instantiation.

- `historySize` - maximum number of history lines retained. Defaults to `30`.

The `completer` function is given the current line entered by the user, and
is supposed to return an Array with 2 entries:

1. An Array with matching entries for the completion.

2. The substring that was used for the matching.

Which ends up looking something like:
`[[substr1, substr2, ...], originalsubstring]`.

Example:

function completer(line) {
var completions = '.help .error .exit .quit .q'.split(' ')
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 })
// show all completions if none found
return [hits.length ? hits : completions, line]
}

Also `completer` can be run in async mode if it accepts two arguments:

function completer(linePartial, callback) {
callback(null, [['123'], linePartial]);
}

`createInterface` is commonly used with `process.stdin` and
`process.stdout` in order to accept user input:

var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

Once you have a readline instance, you most commonly listen for the
`"line"` event.

If `terminal` is `true` for this instance then the `output` stream will get
the best compatibility if it defines an `output.columns` property, and fires
a `"resize"` event on the `output` if/when the columns ever change
(`process.stdout` does this automatically when it is a TTY).

## Class: Interface

The class that represents a readline interface with an input and output
stream.

### rl.setPrompt(prompt)
### rl.close()

Sets the prompt, for example when you run `node` on the command line, you see
`> `, which is node.js's prompt.
Closes the `Interface` instance, relinquishing control on the `input` and
`output` streams. The "close" event will also be emitted.

### rl.pause()

Pauses the readline `input` stream, allowing it to be resumed later if needed.

Note that this doesn't immediately pause the stream of events. Several events may be emitted after calling `pause`, including `line`.

### rl.prompt([preserveCursor])

Expand Down Expand Up @@ -123,20 +69,14 @@ Example usage:
console.log('Oh, so your favorite food is ' + answer);
});

### rl.pause()

Pauses the readline `input` stream, allowing it to be resumed later if needed.

Note that this doesn't immediately pause the stream of events. Several events may be emitted after calling `pause`, including `line`.

### rl.resume()

Resumes the readline `input` stream.

### rl.close()
### rl.setPrompt(prompt)

Closes the `Interface` instance, relinquishing control on the `input` and
`output` streams. The "close" event will also be emitted.
Sets the prompt, for example when you run `node` on the command line, you see
`> `, which is node.js's prompt.

### rl.write(data[, key])

Expand All @@ -154,6 +94,19 @@ Example:

## Events

### Event: 'close'

`function () {}`

Emitted when `close()` is called.

Also emitted when the `input` stream receives its "end" event. The `Interface`
instance should be considered "finished" once this is emitted. For example, when
the `input` stream receives `^D`, respectively known as `EOT`.

This event is also called if there is no `SIGINT` event listener present when
the `input` stream receives a `^C`, respectively known as `SIGINT`.

### Event: 'line'

`function (line) {}`
Expand Down Expand Up @@ -194,18 +147,23 @@ Example of listening for `resume`:
console.log('Readline resumed.');
});

### Event: 'close'
### Event: 'SIGCONT'

`function () {}`

Emitted when `close()` is called.
**This does not work on Windows.**

Also emitted when the `input` stream receives its "end" event. The `Interface`
instance should be considered "finished" once this is emitted. For example, when
the `input` stream receives `^D`, respectively known as `EOT`.
Emitted whenever the `input` stream is sent to the background with `^Z`,
respectively known as `SIGTSTP`, and then continued with `fg(1)`. This event
only emits if the stream was not paused before sending the program to the
background.

This event is also called if there is no `SIGINT` event listener present when
the `input` stream receives a `^C`, respectively known as `SIGINT`.
Example of listening for `SIGCONT`:

rl.on('SIGCONT', function() {
// `prompt` will automatically resume the stream
rl.prompt();
});

### Event: 'SIGINT'

Expand Down Expand Up @@ -247,25 +205,6 @@ Example of listening for `SIGTSTP`:
console.log('Caught SIGTSTP.');
});

### Event: 'SIGCONT'

`function () {}`

**This does not work on Windows.**

Emitted whenever the `input` stream is sent to the background with `^Z`,
respectively known as `SIGTSTP`, and then continued with `fg(1)`. This event
only emits if the stream was not paused before sending the program to the
background.

Example of listening for `SIGCONT`:

rl.on('SIGCONT', function() {
// `prompt` will automatically resume the stream
rl.prompt();
});


## Example: Tiny CLI

Here's an example of how to use all these together to craft a tiny command
Expand All @@ -292,14 +231,6 @@ line interface:
process.exit(0);
});

## readline.cursorTo(stream, x, y)

Move cursor to the specified position in a given TTY stream.

## readline.moveCursor(stream, dx, dy)

Move cursor relative to it's current position in a given TTY stream.

## readline.clearLine(stream, dir)

Clears current line of given TTY stream in a specified direction.
Expand All @@ -312,3 +243,71 @@ Clears current line of given TTY stream in a specified direction.
## readline.clearScreenDown(stream)

Clears the screen from the current position of the cursor down.

## readline.createInterface(options)

Creates a readline `Interface` instance. Accepts an "options" Object that takes
the following values:

- `input` - the readable stream to listen to (Required).

- `output` - the writable stream to write readline data to (Optional).

- `completer` - an optional function that is used for Tab autocompletion. See
below for an example of using this.

- `terminal` - pass `true` if the `input` and `output` streams should be
treated like a TTY, and have ANSI/VT100 escape codes written to it.
Defaults to checking `isTTY` on the `output` stream upon instantiation.

- `historySize` - maximum number of history lines retained. Defaults to `30`.

The `completer` function is given the current line entered by the user, and
is supposed to return an Array with 2 entries:

1. An Array with matching entries for the completion.

2. The substring that was used for the matching.

Which ends up looking something like:
`[[substr1, substr2, ...], originalsubstring]`.

Example:

function completer(line) {
var completions = '.help .error .exit .quit .q'.split(' ')
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 })
// show all completions if none found
return [hits.length ? hits : completions, line]
}

Also `completer` can be run in async mode if it accepts two arguments:

function completer(linePartial, callback) {
callback(null, [['123'], linePartial]);
}

`createInterface` is commonly used with `process.stdin` and
`process.stdout` in order to accept user input:

var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

Once you have a readline instance, you most commonly listen for the
`"line"` event.

If `terminal` is `true` for this instance then the `output` stream will get
the best compatibility if it defines an `output.columns` property, and fires
a `"resize"` event on the `output` if/when the columns ever change
(`process.stdout` does this automatically when it is a TTY).

## readline.cursorTo(stream, x, y)

Move cursor to the specified position in a given TTY stream.

## readline.moveCursor(stream, dx, dy)

Move cursor relative to it's current position in a given TTY stream.