Fix a few thing with compose
This commit is contained in:
@@ -4,6 +4,7 @@ import { SerializationFormats } from "./baseDefinitions";
|
||||
|
||||
export function parse(
|
||||
format: SerializationFormats = SerializationFormats.utf8,
|
||||
emitError: boolean = true,
|
||||
): Transform {
|
||||
const decoder = new StringDecoder(format);
|
||||
return new Transform({
|
||||
@@ -13,9 +14,13 @@ export function parse(
|
||||
try {
|
||||
const asString = decoder.write(chunk);
|
||||
// Using await causes parsing errors to be emitted
|
||||
callback(undefined, await JSON.parse(asString));
|
||||
callback(null, await JSON.parse(asString));
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
if (emitError) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user