Giter VIP home page Giter VIP logo

Build Status NPM version jDataView - A unique way to work with a binary file in JavaScript.

jDataView provides a layer on top of DataView to make modifying binary data a pleasure.

jDataView is a drop-in replacement for the native DataView, adding methods for setting string, arbitrary-sized integers, and more.

Documentation

History

There are three ways to read a binary file from the browser.

  • The first one is to download the file through XHR with charset=x-user-defined. You get the file as a String, convert it to byte Array and you have to rewrite all the decoding and encoding functions (getUint16, getFloat32, ...). All the browsers support this.

  • Then browsers that implemented Canvas also added CanvasPixelArray as part of ImageData. It is fast byte array that is created and used internally by <canvas /> element for manipulating low-level image data. We can create such host element and use it as factory for our own instances of this array.

  • Then browsers that implemented WebGL added ArrayBuffer. It is a plain buffer that can be read with views called TypedArrays (Int32Array, Float64Array, ...). You can use them to decode the file but this is not very handy. It has big drawback, it can't read non-aligned data (but we can actually hack that). So they replaced CanvasPixelArray with Uint8ClampedArray (same as Uint8Array, but cuts off numbers outside 0..255 range).

  • A new revision of the specification added DataViews. It is a view around your buffer that can read/write arbitrary data types directly through functions: getUint32, getFloat64 ...

And one way to read a binary file from the server.

jDataView provided a polyfill for the DataView API with own convenient extensions using the best available option between Arrays, TypedArrays, NodeJS Buffers and DataViews.

Now that DataView is natively available in all engines, jDataView 3 acts as a layer on top of it with powerful methods for dealing with non-standard binary data types, such as strings and arbitrary-sized integers.

Also check out (jBinary)

For complicated binary structures, it may be hard enough to use only low-level get/set operations for parsing, processing and writing data.

In addition, most likely you might need convenient I/O methods for retrieving data from external sources such like local files (using File API or from Node.js), remote files (via HTTP(S)), data-URIs, Node.js streams etc. as well as for displaying generated content to user on webpage in image/video/audio/... containers or even as simple download link.

If you faced any of these problems, you might want to check out new jBinary library that works on top of jDataView and allows to operate with binary data in structured and convenient way.

Demos

HTTP Live Streaming realtime converter and player demo implemented using jBinary data structures. Screenshot


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


A PhotoSynth WebGL Viewer by Visual Experiments. It uses jDataView to read the binary file and then WebGL to display it. Screenshot


A simple tar viewer. It is a "Hello World" demo of how easy it is to use the library.


JavaScript TrueTypeFont library demo which uses jDataView to read and display glyphs from TrueType file.

--

jBinary.Repo ready-to-use typesets and corresponding demos of using jDataView+jBinary for reading popular file formats like GZIP archives, TAR archives, ICO images, BMP images, MP3 tags etc.


Talking image - animation and audio in one package powered by HTML5 Audio, jDataView and jBinary.


Please tell us if you made something with jDataView :)

jdataview's Projects

dist icon dist

Repo for minified versions of scripts (using gh-pages as CDN).

jbinary icon jbinary

High-level API for working with binary data.

jbinary.repo icon jbinary.repo

Repo for demos of popular structures implemented with jBinary

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.