Socket
Socket
Sign inDemoInstall

jbinary

Package Overview
Dependencies
49
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jbinary

High-level I/O for binary data.


Version published
Weekly downloads
1.7K
decreased by-2.54%
Maintainers
1
Install size
4.16 MB
Created
Weekly downloads
 

Readme

Source

Build Status NPM version jBinary

![Gitter](https://badges.gitter.im/Join Chat.svg)

Binary data in JavaScript is easy!

jBinary makes it easy to create, load, parse, modify and save complex binary files and data structures in both browser and Node.js.

It works on top of jDataView (DataView polyfill with convenient extensions).

Was inspired by jParser and derived as new library with full set of operations for binary data.

How can I use it?

Typical scenario:

  • Describe typeset with JavaScript-compatible declarative syntax (jBinary will do type caching for you).
  • Create jBinary instance from memory or from data source and your typeset.
  • Read/write data just as native JavaScript objects!

API Documentation.

Check out wiki for detailed API documentation.

Is there any example code?

How about TAR archive modification:

// configuring paths for Require.js
// (you can use CommonJS (Component, Node.js) or simple script tags as well)
require.config({
  paths: {
    jdataview: 'https://jdataview.github.io/dist/jdataview',
    jbinary: 'https://unpkg.com/jbinary@2.1.3/dist/browser/jbinary',
    TAR: 'https://jdataview.github.io/jBinary.Repo/typeSets/tar' // TAR archive typeset
  }
});

require(['jbinary', 'TAR'], function (jBinary, TAR) {
  // loading TAR archive with given typeset
  jBinary.load('sample.tar', TAR).then(function (jb/* : jBinary */) {
    // read everything using type aliased in TAR['jBinary.all']
    var files = jb.readAll();

    // do something with files in TAR archive (like rename them to upper case)
    files.forEach(function (file) {
      file.name = file.name.toUpperCase();
    });

    jb.writeAll(files, 0); // writing entire content from files array
    jb.saveAs('sample.new.tar'); // saving file under given name
  });
});

Run or edit it on JSBin.

Show me amazing use-cases!

Advanced demo that shows abilities and performance of jBinary - Apple HTTP Live Streaming player which converts MPEG-TS video chunks from realtime stream to MP4 and plays them immediately one by one while converting few more chunks in background.

Screenshot


A World of Warcraft Model Viewer. It uses jDataView+jBinary to read the binary file and then WebGL to display it.

Screenshot

Also check out jBinary.Repo for advanced usage and demos of some popular file formats (and feel free to submit more!).

What license is it issued under?

This library is provided under MIT license.

Keywords

FAQs

Last updated on 05 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc