From ff47915e5b515c3563bd318bb6656923ed100daa 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 efe24e0ad7a2ee..eef36d24d487e7 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -25,13 +25,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);