How to use the @gmod/binary-parser.Parser.start function in @gmod/binary-parser

To help you get started, we’ve selected a few @gmod/binary-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GMOD / cram-js / src / cramFile / sectionParsers.js View on Github external
cramEncoding(majorVersion) {
    const parser = new Parser()
      .namely('cramEncoding')
      .itf8('codecId')
      .itf8('parametersBytes')
      .choice('parameters', {
        tag: 'codecId',
        choices: {
          0: new Parser(), // NULL
          1: new Parser().itf8('blockContentId'), // EXTERNAL
          2: new Parser().itf8('offset').itf8('M'), // GOLOMB,
          // HUFFMAN_INT
          3: Parser.start()
            .itf8('numCodes')
            .array('symbols', { length: 'numCodes', type: singleItf8 })
            .itf8('numLengths')
            .array('bitLengths', { length: 'numLengths', type: singleItf8 }),
          4: Parser.start() // BYTE_ARRAY_LEN
            .nest('lengthsEncoding', { type: 'cramEncoding' })
            .nest('valuesEncoding', { type: 'cramEncoding' }),
          // BYTE_ARRAY_STOP is a little different for CRAM v1
          5: new Parser()
            .uint8('stopByte')
            [majorVersion > 1 ? 'itf8' : 'int']('blockContentId'),
          6: new Parser().itf8('offset').itf8('length'), // BETA
          7: new Parser().itf8('offset').itf8('K'), // SUBEXP
          8: new Parser().itf8('offset').itf8('log2m'), // GOLOMB_RICE
          9: new Parser().itf8('offset'), // GAMMA
        },
github GMOD / cram-js / src / cramFile / sectionParsers.js View on Github external
.namely('cramEncoding')
      .itf8('codecId')
      .itf8('parametersBytes')
      .choice('parameters', {
        tag: 'codecId',
        choices: {
          0: new Parser(), // NULL
          1: new Parser().itf8('blockContentId'), // EXTERNAL
          2: new Parser().itf8('offset').itf8('M'), // GOLOMB,
          // HUFFMAN_INT
          3: Parser.start()
            .itf8('numCodes')
            .array('symbols', { length: 'numCodes', type: singleItf8 })
            .itf8('numLengths')
            .array('bitLengths', { length: 'numLengths', type: singleItf8 }),
          4: Parser.start() // BYTE_ARRAY_LEN
            .nest('lengthsEncoding', { type: 'cramEncoding' })
            .nest('valuesEncoding', { type: 'cramEncoding' }),
          // BYTE_ARRAY_STOP is a little different for CRAM v1
          5: new Parser()
            .uint8('stopByte')
            [majorVersion > 1 ? 'itf8' : 'int']('blockContentId'),
          6: new Parser().itf8('offset').itf8('length'), // BETA
          7: new Parser().itf8('offset').itf8('K'), // SUBEXP
          8: new Parser().itf8('offset').itf8('log2m'), // GOLOMB_RICE
          9: new Parser().itf8('offset'), // GAMMA
        },
      })

    return { parser }
  },

@gmod/binary-parser

Blazing-fast binary parser builder

MIT
Latest version published 3 months ago

Package Health Score

59 / 100
Full package analysis