Skip to content

Loading from a Node.js project

Ioannis Charalampidis edited this page Jun 7, 2016 · 1 revision

Requirements

You need the following node modules:

npm install --save jbb

Code Example

// Get a reference to the JBB decoder
var JBBDecoder = require('jbb/decoder');

// Add one or more profiles needed by the bundle
loader.addProfile( require('jbb-profile-name/profile-decode') );

// Add one or more bundles to load
loader.add("bundle_name.jbb");
loader.add("sparse_bundle_name.jbbp");

// Load all of them and callback when ready
loader.load(function(err, database) {

   // Handle errors
   if (err) {
      alert("Loading error: "+err);
      return;
   }

   // Handle your data here
   var my_object = database["bundle_name/resource_name"];

});