# binary-markup

> Binary Markup Language - declarative way to describe binary data

Latest version **0.9.0** (published 2019-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install binary-markup
pnpm add binary-markup
yarn add binary-markup
bun add binary-markup
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2019-12-26 |
| First published | 2018-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 425.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Sergii Kostyrko |
| Maintainers | srg-kostyrko |
| Keywords | BML, binary, file, buffer, parse, pack |

## Links

- npm: https://www.npmjs.com/package/binary-markup
- Repository: https://github.com/srg-kostyrko/BML
- Homepage: https://github.com/srg-kostyrko/BML#readme
- Issues: https://github.com/srg-kostyrko/BML/issues
- npm.io page: https://npm.io/package/binary-markup

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.9.0 (latest) — 2019-12-26
- 0.8.6 — 2019-07-14
- 0.8.5 — 2019-07-13
- 0.8.4 — 2019-04-02
- 0.8.3 — 2019-03-19
- 0.8.2 — 2019-03-04
- 0.8.1 — 2019-02-26
- 0.8.0 — 2019-01-15
- 0.7.0 — 2018-12-02
- 0.6.0 — 2018-11-27
- 0.5.0 — 2018-11-22

## README

![Logo of the project](./bml-logo.png)

![NpmLicense](https://img.shields.io/npm/l/binary-markup.svg) ![npm](https://img.shields.io/npm/v/binary-markup.svg)

# BML

> Binary markup language

BML a powerful declarative and symmetrical parser and packer for binary data.

Instead of writing imperative code to parse a piece of data, you declaratively define a data structure that describes your data. And you can use it in one direction to parse data into Javascript objects, and in the other direction, to pack objects into binary data.

## Installing / Getting started

NodeJS: Just use npm to install BML and you are set :)

```shell
npm install binary-markup --save
```

```shell
yarn add binary-markup
```

## Example

First describe structure of binary data

```javascript
const { byte, struct } = require('binary-markup');

// define composite type
const rgb = struct(byte`r`, byte`g`, byte`b`);
// you can use previously defined type to describe more complex ones
const colorsType = struct(rgb`main`, rgb`secondary`);
```

Now you can read and parse binary data

```javascript
const fs = require('fs');
const { parse } = require('binary-markup');

fs.readFile('file.bin', function(err, data) {
  console.log(parse(colorsType, data));
});
```

You can as well convert javascript object to binary data

```javascript
const { pack } = require('binary-markup');

console.log(
  pack(colorsType, {
    main: {
      r: 211,
      g: 33,
      b: 22,
    },
    secondary: {
      r: 255,
      g: 255,
      b: 255,
    },
  })
);
```

## Features

TBD

## Contributing

If you'd like to contribute, please fork the repository and use a feature
branch. Pull requests are warmly welcome.

## Links

- Project homepage: https://github.com/srg-kostyrko/BML
- Repository: https://github.com/srg-kostyrko/BML
- Issue tracker: https://github.com/srg-kostyrko/BML/issues
  - In case of sensitive bugs like security vulnerabilities, please contact
    srg.kostyrko@gmail.com directly instead of using issue tracker. We value your effort
    to improve the security and privacy of this project!
- Related projects:
  - jBinary: https://github.com/jDataView/jBinary - uses similiar concept of descrative type definitions, but no activity recently
  - Construct: https://github.com/construct/construct - Python library, lots of ideas taken from it

## Licensing

The code in this project is licensed under MIT license.

---
_Source: https://npm.io/package/binary-markup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
