diff --git a/lib/bcoin-browser.js b/lib/bcoin-browser.js index 7d151a3d..75c29458 100644 --- a/lib/bcoin-browser.js +++ b/lib/bcoin-browser.js @@ -125,6 +125,28 @@ var bcoin = exports; +/** + * Set the default network. + * @param {String} network + */ + +bcoin.set = function set(network) { + bcoin.network.set(network); + return bcoin; +}; + +/** + * Cache all necessary modules. + */ + +bcoin.cache = function cache() { + ; +}; + +/* + * Expose + */ + // Horrible BIP bcoin.bip70 = require('./bip70'); @@ -249,26 +271,8 @@ bcoin.walletplugin = require('./wallet/plugin'); bcoin.workers = require('./workers'); bcoin.workerpool = require('./workers/workerpool'); -/** - * Set the default network. - * @param {String} network - */ - -bcoin.set = function set(network) { - bcoin.network.set(network); - return bcoin; -}; - -/** - * Cache all necessary modules. - */ - -bcoin.cache = function cache() { - ; -}; - /* - * Expose + * Expose Globally */ global.bcoin = bcoin; diff --git a/lib/bcoin.js b/lib/bcoin.js index 7faceb1e..52c6eae8 100644 --- a/lib/bcoin.js +++ b/lib/bcoin.js @@ -125,6 +125,48 @@ var bcoin = exports; +/** + * Define a module for lazy loading. + * @param {String} name + * @param {String} path + */ + +bcoin.define = function _require(name, path) { + var cache; + bcoin.__defineGetter__(name, function() { + if (!cache) + cache = require(path); + return cache; + }); +}; + +/** + * Set the default network. + * @param {String} network + */ + +bcoin.set = function set(network) { + bcoin.network.set(network); + return bcoin; +}; + +/** + * Cache all necessary modules. + */ + +bcoin.cache = function cache() { + bcoin.bip70; + bcoin.common; + bcoin.crypto; + bcoin.fullnode; + bcoin.http; + bcoin.spvnode; +}; + +/* + * Expose + */ + // Horrible BIP bcoin.define('bip70', './bip70'); @@ -248,39 +290,3 @@ bcoin.define('walletplugin', './wallet/plugin'); // Workers bcoin.define('workers', './workers'); bcoin.define('workerpool', './workers/workerpool'); - -/** - * Set the default network. - * @param {String} network - */ - -bcoin.set = function set(network) { - bcoin.network.set(network); - return bcoin; -}; - -/** - * Cache all necessary modules. - */ - -bcoin.cache = function cache() { - bcoin.bip70; - bcoin.common; - bcoin.crypto; - bcoin.fullnode; - bcoin.http; - bcoin.spvnode; -}; - -/** - * Cache all necessary modules. - */ - -bcoin.define = function _require(name, path) { - var cache; - bcoin.__defineGetter__(name, function() { - if (!cache) - cache = require(path); - return cache; - }); -};