lib/logger.js: use Promise.resolve().then() to call _serializeBuffer,
so it can optionally be async in subclasses.
test/logger-log.js:
test/logger-errors.js: Add tests for async _serializeBuffer, and
error handling thereof.
Note: this looks like a large change but it's not really -- just diff getting confused by the indentation changes
The substance of the change is to go from this:
const data = this._serializeBuffer(buffer)
// do stuff with data
to this:
Promise.resolve(this._serializeBuffer(buffer))
.then((data) => {
// do stuff with data
})
.catch((error) => {
// Handle errors in resolution of _serializeBuffer
})
I did not try to refactor the code in // do stuff with data because it's got a bit too much dependency on shared state vis a vis local variables. I think it's possible to refactor it to make that a bit cleaner but I think that's out of scope for this change.
lib/logger.js: use Promise.resolve().then() to call _serializeBuffer, so it can optionally be async in subclasses.
test/logger-log.js:
test/logger-errors.js: Add tests for async _serializeBuffer, and error handling thereof.
Note: this looks like a large change but it's not really -- just diff getting confused by the indentation changes The substance of the change is to go from this:
to this:
I did not try to refactor the code in
// do stuff with data
because it's got a bit too much dependency on shared state vis a vis local variables. I think it's possible to refactor it to make that a bit cleaner but I think that's out of scope for this change.