INNER CODE UNIT · TypeScript

ByteLengthParser

serialport/node-serialport · packages/parser-byte-length/lib/index.ts:13

export class ByteLengthParser extends Transform {
  length: number
  private position: number
  private buffer: Buffer
  constructor(options: ByteLengthOptions) {
    super(options)

    if (typeof options.length !== 'number') {
      throw new TypeError('"length" is not a number')
    }

    if (options.length < 1) {
      throw new TypeError('"length" is not greater than 0')
    }

    this.length = options.length
    this.position = 0
    this.buffer = Buffer.alloc(this.length)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…