Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meltingice/bindata.js
A structured and understandable way to read/write binary data in Javascript. Inspired by Ruby BinData.
https://github.com/meltingice/bindata.js
Last synced: 24 days ago
JSON representation
A structured and understandable way to read/write binary data in Javascript. Inspired by Ruby BinData.
- Host: GitHub
- URL: https://github.com/meltingice/bindata.js
- Owner: meltingice
- Created: 2012-03-15T23:58:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-04-05T15:06:49.000Z (over 12 years ago)
- Last Synced: 2024-10-07T19:37:49.968Z (about 1 month ago)
- Language: CoffeeScript
- Homepage: http://meltingice.github.com/bindata.js
- Size: 650 KB
- Stars: 10
- Watchers: 6
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BinData.js
BinData.js is a simple and structured way to read and write binary data. Instead of having to remember a whole table of obscure character codes, you can write and encapsulate chunks of binary data together with ease.
BinData.js aims to be a very close port of [Ruby's BinData library](http://bindata.rubyforge.org/).
## Installation
BinData.js is available in npm. Simply run in your project directory:
```
npm install bindata
```## Examples
**Data record definition**
``` coffeescript
{BinData} = require 'bindata'class Rectangle extends BinData.Record
endian: "little"
define: ->
@uint16 "len"
@string "name", length: 4
@uint32 "width"
@uint32 "height"
```**Reading a data record**
``` coffeescript
file = BinData.File.open("/path/to/file")
r = new Rectangle(file)
r.read()console.log "Rectangle #{r.name} is #{r.width} x #{r.height}"
```