Add samples

This commit is contained in:
Sami Turcotte
2018-12-03 00:38:17 -05:00
parent e41abfada4
commit 56fe20dc3c
9 changed files with 44 additions and 26 deletions

View File

@@ -182,7 +182,17 @@ export function reduce<T, R>(
}
},
flush(callback) {
callback(undefined, value);
// Best effort attempt at yielding the final value (will throw if e.g. yielding an object and
// downstream doesn't expect objects)
try {
callback(undefined, value);
} catch (err) {
try {
this.emit("error", err);
} catch {
// Best effort was made
}
}
},
});
}