Skip to content

Commit bdaac04

Browse files
cjihrigMylesBorins
authored andcommitted
wasi: improve use of primordials
PR-URL: #31212 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f7833ac commit bdaac04

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎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

@@ -40,7 +40,7 @@ class WASI {
4040
for(constkeyinenv){
4141
constvalue=env[key];
4242
if(value!==undefined)
43-
envPairs.push(`${key}=${value}`);
43+
ArrayPrototypePush(envPairs,`${key}=${value}`);
4444
}
4545
}elseif(env!==undefined){
4646
thrownewERR_INVALID_ARG_TYPE('options.env','Object',env);
@@ -49,10 +49,9 @@ class WASI {
4949
constpreopenArray=[];
5050

5151
if(typeofpreopens==='object'&&preopens!==null){
52-
ArrayPrototypeForEach(ObjectKeys(preopens),(key)=>{
53-
preopenArray.push(String(key));
54-
preopenArray.push(String(preopens[key]));
55-
});
52+
for(const[key,value]ofObjectEntries(preopens)){
53+
ArrayPrototypePush(preopenArray,String(key),String(value));
54+
}
5655
}elseif(preopens!==undefined){
5756
thrownewERR_INVALID_ARG_TYPE('options.preopens','Object',preopens);
5857
}

0 commit comments

Comments
 (0)