Skip to content

Usage with AMD

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'));
  });
});
Something went wrong with that request. Please try again.