Skip to content

Commit

Permalink
fix: parser-slip-encoder had a breaking change (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
reconbot authored May 26, 2021
1 parent 85297bc commit c89b600
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 2 additions & 6 deletions packages/parser-slip-encoder/lib/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ class SlipEncoder extends Transform {
...options,
}
this.opts = opts

if (options.bluetoothQuirk) {
this._bluetoothQuirk = true
}
}

_transform(chunk, encoding, cb) {
const chunkLength = chunk.length

if (this._bluetoothQuirk && chunkLength === 0) {
if (this.opts.bluetoothQuirk && chunkLength === 0) {
// Edge case: push no data. Bluetooth-quirky SLIP parsers don't like
// lots of 0xC0s together.
return cb()
Expand All @@ -55,7 +51,7 @@ class SlipEncoder extends Transform {
const encoded = Buffer.alloc(chunkLength * 2 + 2)
let j = 0

if (this._bluetoothQuirk == true) {
if (this.opts.bluetoothQuirk == true) {
encoded[j++] = this.opts.END
}

Expand Down
10 changes: 6 additions & 4 deletions packages/parser-slip-encoder/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
SlipEncoder: require('./encoder'),
SlipDecoder: require('./decoder'),
}
const SlipEncoder = require('./encoder')
const SlipDecoder = require('./decoder')

module.exports = SlipEncoder
module.exports.SlipEncoder = SlipEncoder
module.exports.SlipDecoder = SlipDecoder

0 comments on commit c89b600

Please sign in to comment.