From 714eb919cc497307b57e176547ba83fe85656a58 Mon Sep 17 00:00:00 2001 From: himself65 Date: Sat, 4 Jan 2020 11:49:31 +0800 Subject: [PATCH] wasi: refactor destructuring object on constructor PR-URL: https://github.com/nodejs/node/pull/31185 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang Reviewed-By: Anto Aravinth Reviewed-By: Ruben Bridgewater Reviewed-By: Jiawen Geng Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: David Carlier Reviewed-By: Luigi Pinca --- lib/wasi.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/wasi.js b/lib/wasi.js index ff8685cbb06452..cf25cd922660d5 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -26,13 +26,11 @@ class WASI { if (options === null || typeof options !== 'object') throw new ERR_INVALID_ARG_TYPE('options', 'object', options); - // eslint-disable-next-line prefer-const - let { args, env, preopens } = options; + const { env, preopens } = options; + let { args = [] } = options; if (ArrayIsArray(args)) args = ArrayPrototypeMap(args, (arg) => { return String(arg); }); - else if (args === undefined) - args = []; else throw new ERR_INVALID_ARG_TYPE('options.args', 'Array', args);