Giter Site home page Giter Site logo

njh / binmark-js Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 28 KB

Markup language and tool for generating binary files

Home Page: https://www.aelius.com/njh/binmark/

License: MIT License

JavaScript 1.19% TypeScript 98.81%
binary hex hexadecimal javascript-library markup-language binmark

binmark-js's Introduction

binmark.js

binmark is a markup language and JavaScript library for describing binary files, that is easier to read and write than a continuous stream of hexadecimal characters.

The following characters are supported:

Character Description
0-9 and a-f A byte as hexadecimal. Must be two characters long.
Whitespace Ignored
Colon or Dash Ignored - useful for improving readability
.nnn A 8-bit decimal integer
"" A string of ASCII characters
# The start of a comment - the rest of the line is ignored
\ Escape sequences (\0 \a \b \f \n \r \t \v)

Example

Given the following sample input file, which is reasonably easy read:

30             # Packet Type 3: Publish
.17            # Remaining length (17 bytes)
0004           # Topic name length
"test"         # Topic name
"hello world"  # Payload

But why?

I created binmark after my test cases, when writing test cases for my Arduino IPv6 Library, EtherSia, started resulting in long strings of hexadecimal characters in my code. I decided that these would be better in seperate external files and realised that I had the freedom to decide on the file format, to make them easier to read and write.

A long stream of hexadecimal is difficult to both read and write - particularly picking out the different fields and sections. By adding some whitespace, punctuation and comments, it is much easier.

Possible uses:

  • Describing expected data for automated tests
  • Creating new file formats before tools to generate them exist
  • Documenting a data structure in a human readable way
  • Alternative to a using a hex editor

Design Decisions

This was my thought process while designing binmark:

  • Readable and concise to write for humans
  • Simple for a machine to parse and convert
  • Streamable - don't require input to be loaded into a buffer more parsing
  • ASCII input - try and avoid potential weird character-set problems
  • Not so complex that there wouldn't be other implementations in other languages

Other Languages

License

binmark is licensed under the terms of the MIT license. See the file LICENSE for details.

Contact

  • Author: Nicholas J Humfrey
  • Twitter: @njh

binmark-js's People

Contributors

njh avatar

Watchers

 avatar

binmark-js's Issues

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.