Skip to content

Commit 7413415

Browse files
committed
Remove reduce in CompilerManagerHook promise chain
That promise chain could be simplified too though
1 parent 4919914 commit 7413415

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/common/CompilerManagerHook.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ function attachCompilerAndLibraries(version, libraries, param) {
105105
})];
106106
return Promise.all(tmp);
107107
}).then(function (all) {
108-
var errors = Belt_Array.reduce(all, [], (function (acc, r) {
108+
var errors = Belt_Array.keepMap(all, (function (r) {
109109
if (r.TAG === /* Ok */0) {
110-
return acc;
110+
return ;
111111
} else {
112-
return acc.concat([r._0]);
112+
return r._0;
113113
}
114114
}));
115115
if (errors.length !== 0) {

src/common/CompilerManagerHook.res

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ let attachCompilerAndLibraries = (~version: string, ~libraries: array<string>, (
126126
Promise.all(promises)
127127
})
128128
->Promise.map(all => {
129-
// all: array(Promise.result(unit, string))
130-
let errors = Belt.Array.reduce(all, [], (acc, r) =>
129+
let errors = Belt.Array.keepMap(all, r => {
131130
switch r {
132-
| Error(msg) => Js.Array2.concat(acc, [msg])
133-
| _ => acc
131+
| Error(msg) => Some(msg)
132+
| _ => None
134133
}
135-
)
134+
})
136135

137136
switch errors {
138137
| [] => Ok()

0 commit comments

Comments
 (0)