Giter Site home page Giter Site logo

binopsy's Introduction

binopsy

Reimplementation of keichi/binary-parser, supporting both streams and serialization.

The API is mainly the same as binary-parser's, with a couple of additions and one removed method.

Dropped support for .skip

Due to undefined behavior, .skip is not supported. As a workaround the .buffer method can be used.

.stream

The .stream method returns a transform stream that reads incoming data and emits parser results. The parser instance is looped until the end of the input is reached.

.serialize

As a counterpart to binary-parser's .parse method, .serialize takes an object and returns a buffer representation of it. Optionally, an already allowcated buffer can be passed as a second argument.

.fixedSizeNest

.fixedSizeNest is a variation of nest that ensures the nested parser reads a specific amount of bytes. Fixed-size nested parsers are the only source of ambiguity remaining while serializing, as missing bytes are simply skipped. And error is thrown during serialization if the nested parser attempts to write more bytes than the size permits.

formatters require a deformatter

Properties with a specified formatting function need to also provide a deformatter function that restores the original value.

flatten option

As a very simple extension, the flatten option allows nested parsers to write to the current object. Its motivation is the aim for a flat output structure after .choice calls.

Bitfields can be (almost) infinitely long

A relaxation from the 32 bit limit of binary-parser. Also, a bug of the original project that leads to the bit32 method always parsing a value of 0 is not present.

License: MIT

binopsy's People

Contributors

dependabot[bot] avatar fb55 avatar greenkeeper[bot] avatar mlasak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

binopsy's Issues

Parsing issue with empty Arrays

Watch this simple example using the binopsy parser vs. the original binary-parser. We expect to end up with the same result, but some data is missing when using binopsy.

const Binopsy = require('binopsy').Parser;
const BinaryParser = require('binary-parser').Parser;

function makeParser(Parser) {
  const inner = Parser.start()
    .string('airportCode', {
      length: 3,
    })
    .uint8('count')
    .array('subs', {
      type: Parser.start()
        .uint8('val'),
      length: 'count',
    });

  const outter = Parser.start()
    .uint8('type')
    .choice('inner', {
      tag: 'type',
      choices: {
        1: inner,
        2: inner,
      },
    });
  return outter;
}

const binopsy = makeParser(Binopsy);
const binaryParser = makeParser(BinaryParser);

const buf = binopsy.serialize({
  type: 1,
  inner: {
    airportCode: 'BER',
    count: 0,
    subs: [],
  },
});
console.log(buf);
console.log(JSON.stringify(binopsy.parse(buf), null, 2));
console.log(JSON.stringify(binaryParser.parse(buf), null, 2));

The output:

<Buffer 01 42 45 52 00>
{
  "type": 1,
  "inner": null
}
{
  "type": 1,
  "inner": {
    "airportCode": "BER",
    "count": 0,
    "subs": []
  }
}

Any ideas on how to fix this?
Thanks anyway for the nice serializing feature!

BR,
Martin

An in-range update of mocha is breaking the build 🚨

Version 3.3.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details - ❌ **continuous-integration/travis-ci/push** The Travis CI build failed [Details](https://travis-ci.org/fb55/binopsy/builds/225173395)

Release Notes coverave

Thanks to all our contributors, maintainers, sponsors, and users! ❀️

As highlights:

  • We've got coverage now!
  • Testing is looking less flaky \o/.
  • No more nitpicking about "mocha.js" build on PRs.

πŸŽ‰ Enhancements

  • #2659: Adds support for loading reporter from an absolute or relative path (@sul4bh)
  • #2769: Support --inspect-brk on command-line (@igwejk)

πŸ› Fixes

  • #2662: Replace unicode chars w/ hex codes in HTML reporter (@rotemdan)

πŸ” Coverage

πŸ”© Other

Commits

The new version differs by 89 commits0.

  • fb1687e :ship: Release v3.3.0
  • 1943e02 Add Changelog for v3.3.0
  • 861e968 Refactor literal play-icon hex code to a var
  • 1d3c5bc Fix typo in karma.conf.js
  • 9bd9389 Fix spec paths in test HTML files
  • 0a93024 Adds tests for loading reporters w/ relative/absolute paths (#2773)
  • 73929ad Comment special treatment of '+' in URL query parsing
  • e2c9514 Merge pull request #2769 from igwejk/support_inspect_break_in_opts
  • 038c636 Support --inspect-brk on command-line
  • b4ebabd Merge pull request #2727 from lamby/reproducible-build
  • 882347b Please make the build reproducible.
  • a2fc76c Merge pull request #2703 from seppevs/cover_utils_some_fn_with_tests
  • ed61cd0 cover .some() function in utils.js with tests
  • f42cbf4 Merge pull request #2701 from craigtaub/landingSpec
  • 6065242 use stubbed symbol

There are 89 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of binary-parser is breaking the build 🚨

Version 1.1.6 of binary-parser just got published.

Branch Build failing 🚨
Dependency binary-parser
Current Version 1.1.5
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

binary-parser is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits.

  • ef2fc58 Bumpt to 1.1.6
  • a093ae8 Merge pull request #47 from kertal/kertal-pull-1
  • 7ab1dd3 Fix for issue #45, the buffer parser eof option now works
  • d7d2fd1 Migrating from Shippable to CircleCI
  • f0a68bb Fix code coverage report at CI
  • 347b075 Measure code coverage using istanbul
  • b15e2a4 Update CI node version

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.