From d2ee7e20b20e354e035020e7b7e350abf222177c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 9 Feb 2017 21:29:56 -0800 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/11281 Reviewed-By: Yuta Hiroto Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-readline-keys.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 39c8aa0668266f..1b05b06f58f04f 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -3,7 +3,6 @@ const common = require('../common'); const PassThrough = require('stream').PassThrough; const assert = require('assert'); const inherits = require('util').inherits; -const extend = require('util')._extend; const Interface = require('readline').Interface; @@ -12,6 +11,10 @@ function FakeInput() { } inherits(FakeInput, PassThrough); +function extend(k) { + return Object.assign({ ctrl: false, meta: false, shift: false }, k); +} + const fi = new FakeInput(); const fo = new FakeInput(); @@ -32,9 +35,7 @@ function addTest(sequences, expectedKeys) { expectedKeys = [ expectedKeys ]; } - expectedKeys = expectedKeys.map((k) => { - return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k; - }); + expectedKeys = expectedKeys.map(extend); keys = []; @@ -65,9 +66,7 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550, expectedKeys = [ expectedKeys ]; } - expectedKeys = expectedKeys.map((k) => { - return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k; - }); + expectedKeys = expectedKeys.map(extend); const keys = []; fi.on('keypress', (s, k) => keys.push(k));