decoder.js
function( url, callback ) {

		// Node quick, not present on browser builds
		if (IS_NODE) {

			// Helper function
			var readChunk = function ( filename ) {
				// Read into buffer
				var file = fs.readFileSync(filename),
					u8 = new Uint8Array(file);
				// Return buffer
				return u8.buffer;
			}

			// Read by chunks
			if (url.substr(-5) === ".jbbp") {

				// Add by buffer
				var base = url.substr(0,url.length-5);
				this.addByBuffer( [
					readChunk(base + '.jbbp'),
					readChunk(base + '_b16.jbbp'),
					readChunk(base + '_b32.jbbp'),
					readChunk(base + '_b64.jbbp'),
				], callback );

			} else {

				// Add by buffer
				this.addByBuffer( readChunk(url), callback );

			}

			// Don't continue on browser builds
			return;

		}

		// Check for base dir
		var prefix = "";
		if (this.baseDir)
			prefix = this.baseDir + "/";

		// Check for sparse bundle
		var parts = url.split("?"), suffix = "", reqURL = [];
		if (parts.length > 1) suffix = "?"+parts[1];
		if (parts[0].substr(parts[0].length - 5).toLowerCase() === ".jbbp") {
			var base = prefix + parts[0].substr(0, parts[0].length - 5);
			reqURL = [
				base + '.jbbp' + suffix,
				base + '_b16.jbbp' + suffix,
				base + '_b32.jbbp' + suffix,
				base + '_b64.jbbp' + suffix
			];
		} else {
			// Assume .jbb if missing (TODO: not a good idea)
			var url = parts[0];
			if (url.substr(url.length-4) != ".jbb") url += ".jbb";
			reqURL = [ prefix + url + suffix ];
		}

		// Load bundle header and keep a callback
		// for the remainging loading operations
		var pendingBundle = {
			'callback': callback,
			'status': PBUND_REQUESTED,
			'buffer': undefined,
			'url': reqURL
		};

		// Keep this pending action
		this.queuedRequests.push( pendingBundle );

	}
function( url, callback ) {

		// Node quick, not present on browser builds
		if (IS_NODE) {

			// Helper function
			var readChunk = function ( filename ) {
				// Read into buffer
				var file = fs.readFileSync(filename),
					u8 = new Uint8Array(file);
				// Return buffer
				return u8.buffer;
			}

			// Read by chunks
			if (url.substr(-5) === ".jbbp") {

				// Add by buffer
				var base = url.substr(0,url.length-5);
				this.addByBuffer( [
					readChunk(base + '.jbbp'),
					readChunk(base + '_b16.jbbp'),
					readChunk(base + '_b32.jbbp'),
					readChunk(base + '_b64.jbbp'),
				], callback );

			} else {

				// Add by buffer
				this.addByBuffer( readChunk(url), callback );

			}

			// Don't continue on browser builds
			return;

		}

		// Check for base dir
		var prefix = "";
		if (this.baseDir)
			prefix = this.baseDir + "/";

		// Check for sparse bundle
		var parts = url.split("?"), suffix = "", reqURL = [];
		if (parts.length > 1) suffix = "?"+parts[1];
		if (parts[0].substr(parts[0].length - 5).toLowerCase() === ".jbbp") {
			var base = prefix + parts[0].substr(0, parts[0].length - 5);
			reqURL = [
				base + '.jbbp' + suffix,
				base + '_b16.jbbp' + suffix,
				base + '_b32.jbbp' + suffix,
				base + '_b64.jbbp' + suffix
			];
		} else {
			// Assume .jbb if missing (TODO: not a good idea)
			var url = parts[0];
			if (url.substr(url.length-4) != ".jbb") url += ".jbb";
			reqURL = [ prefix + url + suffix ];
		}

		// Load bundle header and keep a callback
		// for the remainging loading operations
		var pendingBundle = {
			'callback': callback,
			'status': PBUND_REQUESTED,
			'buffer': undefined,
			'url': reqURL
		};

		// Keep this pending action
		this.queuedRequests.push( pendingBundle );

	}
function ( url , callback ) { // Node quick, not present on browser builds if ( IS_NODE ) { // Helper function var readChunk = function ( filename ) { // Read into buffer var file = fs . readFileSync ( filename ) , u8 = new Uint8Array ( file ) ; // Return buffer return u8 . buffer ; } // Read by chunks if ( url . substr ( - 5 ) === ".jbbp" ) { // Add by buffer var base = url . substr ( 0 , url . length - 5 ) ; this . addByBuffer ( [ readChunk ( base + '.jbbp' ) , readChunk ( base + '_b16.jbbp' ) , readChunk ( base + '_b32.jbbp' ) , readChunk ( base + '_b64.jbbp' ) , ] , callback ) ; } else { // Add by buffer this . addByBuffer ( readChunk ( url ) , callback ) ; } // Don't continue on browser builds return ; } // Check for base dir var prefix = "" ; if ( this . baseDir ) prefix = this . baseDir + "/" ; // Check for sparse bundle var parts = url . split ( "?" ) , suffix = "" , reqURL = [ ] ; if ( parts . length > 1 ) suffix = "?" + parts [ 1 ] ; if ( parts [ 0 ] . substr ( parts [ 0 ] . length - 5 ) . toLowerCase ( ) === ".jbbp" ) { var base = prefix + parts [ 0 ] . substr ( 0 , parts [ 0 ] . length - 5 ) ; reqURL = [ base + '.jbbp' + suffix , base + '_b16.jbbp' + suffix , base + '_b32.jbbp' + suffix , base + '_b64.jbbp' + suffix ] ; } else { // Assume .jbb if missing (TODO: not a good idea) var url = parts [ 0 ] ; if ( url . substr ( url . length - 4 ) != ".jbb" ) url += ".jbb" ; reqURL = [ prefix + url + suffix ] ; } // Load bundle header and keep a callback // for the remainging loading operations var pendingBundle = { 'callback' : callback , 'status' : PBUND_REQUESTED , 'buffer' : undefined , 'url' : reqURL } ; // Keep this pending action this . queuedRequests . push ( pendingBundle ) ; }
Load the specified bundle from URL and call the onsuccess callback.
If an error occures, call the onerror callback.

@param {string} url - The URL to load
@param {function} callback - The callback to fire when the bundle is loaded
Load the specified bundle from URL and call the onsuccess callback . If an error occures call the onerror callback .