Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
option name & alignment fix
  • Loading branch information
princejwesley committed Aug 21, 2016
commit f5cf5316ab7af01ee1a544f2cc4ae23508e8075d
4 changes: 2 additions & 2 deletions doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ added: v0.1.98
only if `terminal` is set to `true` by the user or by an internal `output`
check, otherwise the history caching mechanism is not initialized at all.
* `prompt` - the prompt string to use. Default: `'> '`
* `crLfDelay` {number} If the delay between `\r` and `\n` exceeds
`crLfDelay`, both `\r` and `\n` will be treated as separate end-of-line
* `crlfDelay` {number} If the delay between `\r` and `\n` exceeds
`crlfDelay`, both `\r` and `\n` will be treated as separate end-of-line
input. Default to `100` milliseconds.

The `readline.createInterface()` method creates a new `readline.Interface`
Expand Down
28 changes: 14 additions & 14 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'use strict';

const kHistorySize = 30;
const kCRLFDelayInMillis = 100;
const kcrlfDelayInMillis = 100;

const util = require('util');
const debug = util.debuglog('readline');
Expand All @@ -22,19 +22,19 @@ const stripVTControlCharacters = internalReadline.stripVTControlCharacters;


exports.createInterface = function(input, output, completer, terminal,
crLfDelay = kCRLFDelayInMillis) {
crlfDelay = kcrlfDelayInMillis) {
var rl;
if (arguments.length === 1) {
rl = new Interface(input);
} else {
rl = new Interface(input, output, completer, terminal, crLfDelay);
rl = new Interface(input, output, completer, terminal, crlfDelay);
}
return rl;
};


function Interface(input, output, completer, terminal,
crLfDelay = kCRLFDelayInMillis) {
crlfDelay = kcrlfDelayInMillis) {
if (!(this instanceof Interface)) {
// call the constructor preserving original number of arguments
const self = Object.create(Interface.prototype);
Expand All @@ -59,8 +59,8 @@ function Interface(input, output, completer, terminal,
if (input.prompt !== undefined) {
prompt = input.prompt;
}
if (input.crLfDelay !== undefined) {
crLfDelay = input.crLfDelay;
if (input.crlfDelay !== undefined) {
crlfDelay = input.crlfDelay;
}
input = input.input;
}
Expand All @@ -79,10 +79,10 @@ function Interface(input, output, completer, terminal,
throw new TypeError('Argument "historySize" must be a positive number');
}

if (typeof crLfDelay !== 'number' ||
isNaN(crLfDelay) ||
crLfDelay <= 0) {
throw new TypeError('Argument "crLfDelay" must be a positive number > 0');
if (typeof crlfDelay !== 'number' ||
isNaN(crlfDelay) ||
crlfDelay <= 0) {
throw new TypeError('Argument "crlfDelay" must be a positive number > 0');
}

// backwards compat; check the isTTY prop of the output stream
Expand All @@ -96,7 +96,7 @@ function Interface(input, output, completer, terminal,
this.output = output;
this.input = input;
this.historySize = historySize;
this.crLfDelay = crLfDelay;
this.crlfDelay = crlfDelay;

// Check arity, 2 - for async, 1 for sync
if (typeof completer === 'function') {
Expand Down Expand Up @@ -355,7 +355,7 @@ Interface.prototype._normalWrite = function(b) {
}
var string = this._decoder.write(b);
if (this._sawReturnAt &&
Date.now() - this._sawReturnAt <= this.crLfDelay) {
Date.now() - this._sawReturnAt <= this.crlfDelay) {
string = string.replace(/^\n/, '');
this._sawReturnAt = 0;
}
Expand Down Expand Up @@ -866,9 +866,9 @@ Interface.prototype._ttyWrite = function(s, key) {
break;

case 'enter':
// When key interval > crLfDelay
// When key interval > crlfDelay
if (this._sawReturnAt === 0 ||
Date.now() - this._sawReturnAt > this.crLfDelay) {
Date.now() - this._sawReturnAt > this.crlfDelay) {
this._line();
}
this._sawReturnAt = 0;
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ function isWarned(emitter) {
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal});
assert.strictEqual(rli.historySize, 30);

// default crLfDelay is 100ms
// default crlfDelay is 100ms
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal});
assert.strictEqual(rli.crLfDelay, 100);
assert.strictEqual(rli.crlfDelay, 100);

fi.emit('data', 'asdf\n');
assert.deepStrictEqual(rli.history, terminal ? ['asdf'] : undefined);
Expand Down Expand Up @@ -205,15 +205,15 @@ function isWarned(emitter) {
rli.close();

// Emit two line events when the delay
// between \r and \n exceeds crLFDelay
// between \r and \n exceeds crlfDelay
{
const fi = new FakeInput();
const delay = 200;
const rli = new readline.Interface({
input: fi,
output: fi,
terminal: terminal,
crLfDelay: delay
crlfDelay: delay
});
let callCount = 0;
rli.on('line', function(line) {
Expand Down