All Projects → screeny05 → Corrode

screeny05 / Corrode

Licence: mit
A batteries-included library for reading binary data.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Corrode

node-pg-large-object
Large object support for PostgreSQL clients using the node-postgres library.
Stars: ✭ 31 (-73.28%)
Mutual labels:  stream, buffer
sirdez
Glorious Binary Serialization and Deserialization for TypeScript.
Stars: ✭ 20 (-82.76%)
Mutual labels:  binary, buffer
NALib
General purpose C sourcecode collection
Stars: ✭ 16 (-86.21%)
Mutual labels:  binary, buffer
Formatfuzzer
FormatFuzzer is a framework for high-efficiency, high-quality generation and parsing of binary inputs.
Stars: ✭ 117 (+0.86%)
Mutual labels:  parsing, binary
Csv
CSV Decoding and Encoding for Elixir
Stars: ✭ 398 (+243.1%)
Mutual labels:  stream, parsing
binary
Clojure API for binary format I/O using java's stream apis
Stars: ✭ 67 (-42.24%)
Mutual labels:  stream, binary
RingBuffer
Classic ringbuffer with optional Stream interface
Stars: ✭ 53 (-54.31%)
Mutual labels:  stream, buffer
Write
Write data to the file system, creating any intermediate directories if they don't already exist. Used by flat-cache and many others!
Stars: ✭ 68 (-41.38%)
Mutual labels:  stream, buffer
structures
Declarative binary data builder and parser: simple, fast, extensible
Stars: ✭ 29 (-75%)
Mutual labels:  parsing, binary
buffertools-php
Toolbox for working with binary and hex data. Similar to NodeJS Buffer.
Stars: ✭ 60 (-48.28%)
Mutual labels:  binary, buffer
Binjs Ref
Reference implementation for the JavaScript Binary AST format
Stars: ✭ 399 (+243.97%)
Mutual labels:  parsing, binary
Bytearray.js
An equivalent to Actionscript 3's ByteArray for Javascript with AMF0 and AMF3 support.
Stars: ✭ 100 (-13.79%)
Mutual labels:  binary, buffer
Yacep
yet another csharp expression parser
Stars: ✭ 107 (-7.76%)
Mutual labels:  parsing
Safe
SAFE: Self-Attentive Function Embeddings for binary similarity
Stars: ✭ 112 (-3.45%)
Mutual labels:  binary
Render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
Stars: ✭ 1,562 (+1246.55%)
Mutual labels:  binary
Cliflix
Watch anything instantaneously, just write its name.
Stars: ✭ 1,439 (+1140.52%)
Mutual labels:  stream
Stacktracey
Parses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.
Stars: ✭ 115 (-0.86%)
Mutual labels:  parsing
Bepasty Server
binary pastebin server
Stars: ✭ 111 (-4.31%)
Mutual labels:  binary
How To Understand Streams In Nodejs
🚰 A step by step explanation how to take advantage of Streams in NodeJS
Stars: ✭ 106 (-8.62%)
Mutual labels:  stream
Illuminati
This is a Platform that collects all the data accuring in your Application and shows the data in real time by using Kibana or other tools.
Stars: ✭ 106 (-8.62%)
Mutual labels:  stream

∆ corrode

MIT license NPM version dependencies coverage build status docs

Corrode is a batteries-included library for reading binary data. It helps you converting that blob-mess into useable data.

Use it to parse that one obscure binary-file with the help of JavaScript.

Install

$ npm install --save corrode

Tests

$ npm test

Offline Docs

$ npm run docs
$ open doc/index.html

What's this?

corrode provides standard read-actions like uint8-uint64 for big & little endian, strings, buffers and control-structures like loops, skipping, etc. for your buffers and files. Additionally you can use assertions to always be sure, the data you parse corresponds to a specified format. The parsing is done not by a configuration-object, but by imperative code, allowing for far greater flexibility.

corrode is an abstraction on top of TransformStream and as such is pipeable to but also provides functions for more simple usage.

This library is not only heavily inspired by dissolve, it in fact can be seen as a total rewrite with even more features. The code is written in ES7, fully documented and tested.

Quick examples

const Corrode = require('corrode');
const parser = new Corrode();

parser
    .uint8('val_1')
    .uint32('val_2')
    .int16be('val_3')
    .tap(function(){
        console.log(this.vars.val_1 * this.vars.val_3);
    })
    .repeat('array', 5, function(){
        this
            .uint32('array_val_1')
            .string('array_val_4', 5);
    });

Parsing a buffer

parser.fromBuffer(buffer, () => console.log(parser.vars));

Parsing a filestream

var stream = fs.createReadStream(file);
stream.pipe(parser);
parser.on('finish', () => console.log(parser.vars));

These are just some of the very basic operations supported by Corrode.

Examples

All examples can be found in the examples/-folder. Included:

  • ID3v2.3-Parser - strict, unforgiving parser for a subset of the standard used to store meta-data in mp3-files. It needs npm i image-to-ascii temp and can be run with node examples/id3 test.mp3.

If you'd like to include your own examples, just open a PR. I'm more than happy to not have to think about existing complex structured binary data to parse myself.

Documentation & API Reference

Why use corrode over dissolve

It solves most of the major shortcomings dissolve has:

  • EOF terminates corrode. If not explicitly asked not to do so it will give you all variables, without you having to fiddle with its intestines.
  • Loops get unwinded correctly.
  • Thoroughly tested.
  • As a js-library from 2016 it has all the swag you need.

When not to use corrode

  • Your data is too complex - If you need to apply black magic on your data, to retrieve meaningful values, corrode currently may not support your use-case.
  • Your data is really simple - If you don't need to read structured data, but instead just numbers or strings you should simply use the built-in read-functions provided by Buffer.

Not yet included are additions like bignum-support for int64 and additional non-node-standard-encodings.

corrode also works in browsers. You will need a setImmediate() polyfill, but you're able to parse ArrayBuffers as usual.

Used dependencies (3)

The following dependencies are installed when installing corrode:

  • bl - used for buffering data, in case a job gets greedy or you don't want to auto-flush
  • readable-streams - ensures consistent and stable behaviour of the underlying Transform-Stream
  • lodash - several utility functions

License

This library is issued under the MIT license.

The Logo is from The Noun Project, created by Michael Senkow and licensed under the CC-BY-3.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].