Skip to content

Commit 7e9779a

Browse files
TrottMylesBorins
authored andcommitted
test: refactor test-readline-keys
* replace `util._extend()` with `Object.assign()` * extract repeated map function to a single instance * remove unneeded truthiness-check ternary on Objects Backport-PR-URL: #16947 PR-URL: #11281 Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 26c4224 commit 7e9779a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/parallel/test-readline-keys.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const common = require('../common');
33
const PassThrough = require('stream').PassThrough;
44
const assert = require('assert');
55
const inherits = require('util').inherits;
6-
const extend = require('util')._extend;
76
const Interface = require('readline').Interface;
87

98

@@ -12,6 +11,10 @@ function FakeInput() {
1211
}
1312
inherits(FakeInput, PassThrough);
1413

14+
function extend(k) {
15+
return Object.assign({ ctrl: false, meta: false, shift: false }, k);
16+
}
17+
1518

1619
const fi = new FakeInput();
1720
const fo = new FakeInput();
@@ -32,9 +35,7 @@ function addTest(sequences, expectedKeys) {
3235
expectedKeys = [ expectedKeys ];
3336
}
3437

35-
expectedKeys = expectedKeys.map(function(k) {
36-
return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k;
37-
});
38+
expectedKeys = expectedKeys.map(extend);
3839

3940
keys = [];
4041

@@ -65,9 +66,7 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550,
6566
expectedKeys = [ expectedKeys ];
6667
}
6768

68-
expectedKeys = expectedKeys.map(function(k) {
69-
return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k;
70-
});
69+
expectedKeys = expectedKeys.map(extend);
7170

7271
const keys = [];
7372
fi.on('keypress', (s, k) => keys.push(k));

0 commit comments

Comments
 (0)