GithubHelp home page GithubHelp logo

jdataview's Introduction

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

jDataView provides convenient way to read and/or modify binary data in all the browsers. It follows the DataView Specification and even extends it for a more practical use.

Explanation

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 provides the DataView API with own convenient extensions using the best available option between Arrays, TypedArrays, NodeJS Buffers and DataViews.

Documentation

Advanced usage (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

Please tell us if you made something with jDataView :)

License

jDataView is issued under Do What The Fuck You Want To Public License :)

jdataview's People

Contributors

rreverser avatar vjeux avatar mmthomas avatar scintill avatar gmarty avatar mithgol avatar clockworkgeek avatar nelhage avatar reggino avatar divergentdave avatar

Watchers

Navid Nikpour avatar  avatar

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.