bcoin: refactor.

This commit is contained in:
Christopher Jeffrey 2017-06-27 01:57:34 -07:00
parent 1aa0858f7c
commit 56252921c1
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 65 additions and 55 deletions

View File

@ -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;

View File

@ -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;
});
};