Skip to content
Ingvar Stepanyan edited this page Sep 13, 2013 · 5 revisions

jBinary supports dynamic loading via AMD too:

// somewhere in config:
require.config({
  paths: {
    jdataview: '//jdataview.github.io/dist/jdataview.js',
    jbinary: '//jdataview.github.io/dist/jbinary.js',
  }
});

// ...

// in code:
require(['jbinary'], function (jBinary) {
  var typeSet = {
    magic: ['array', 'uint8', 4]
  };

  jBinary.load('file.bin', typeSet, function (err, binary) {
    console.log(binary.read('magic'));
  });
});
Clone this wiki locally