Skip to content

Commit a91a824

Browse files
cjihrigcodebytere
authored andcommitted
wasi: improve use of primordials
PR-URL: #31212 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 41f0fa7 commit a91a824

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/wasi.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/* global WebAssembly */
33
const {
44
ArrayIsArray,
5-
ArrayPrototypeForEach,
65
ArrayPrototypeMap,
6+
ArrayPrototypePush,
77
FunctionPrototypeBind,
8-
ObjectKeys,
8+
ObjectEntries,
99
Symbol,
1010
} = primordials;
1111
const {
@@ -39,7 +39,7 @@ class WASI {
3939
for (const key in env) {
4040
const value = env[key];
4141
if (value !== undefined)
42-
envPairs.push(`${key}=${value}`);
42+
ArrayPrototypePush(envPairs, `${key}=${value}`);
4343
}
4444
} else if (env !== undefined) {
4545
throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env);
@@ -48,10 +48,9 @@ class WASI {
4848
const preopenArray = [];
4949

5050
if (typeof preopens === 'object' && preopens !== null) {
51-
ArrayPrototypeForEach(ObjectKeys(preopens), (key) => {
52-
preopenArray.push(String(key));
53-
preopenArray.push(String(preopens[key]));
54-
});
51+
for (const [key, value] of ObjectEntries(preopens)) {
52+
ArrayPrototypePush(preopenArray, String(key), String(value));
53+
}
5554
} else if (preopens !== undefined) {
5655
throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens);
5756
}

0 commit comments

Comments
 (0)