From 020d09a6fe5fbf21b361cfb32412713af5639610 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 13 May 2016 09:34:09 -0700 Subject: [PATCH] expose function. --- lib/bcoin.js | 12 +++++++++--- lib/bcoin/env.js | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/bcoin.js b/lib/bcoin.js index be417fb5..42e3b4f5 100644 --- a/lib/bcoin.js +++ b/lib/bcoin.js @@ -7,7 +7,7 @@ * https://github.com/indutny/bcoin */ -var Environment = require('./bcoin/env'); +var env = require('./bcoin/env'); var utils = require('./bcoin/utils'); var global = utils.global; @@ -22,5 +22,11 @@ if (utils.isBrowser) * @returns {Environment} */ -utils.merge(exports, Environment.prototype); -Environment.call(exports); +function BCoin(options) { + env.setDefaults(options); + return BCoin; +} + +utils.merge(BCoin, env); + +module.exports = BCoin; diff --git a/lib/bcoin/env.js b/lib/bcoin/env.js index 8f9ca054..918253dd 100644 --- a/lib/bcoin/env.js +++ b/lib/bcoin/env.js @@ -198,6 +198,9 @@ function Environment(options) { } Environment.prototype.setDefaults = function setDefaults(options) { + if (typeof options === 'string') + options = { network: options }; + options = utils.merge({}, options); options.prefix = options.prefix @@ -327,4 +330,5 @@ Environment.prototype.now = function now() { return this.time.now(); }; -module.exports = Environment; +utils.merge(exports, Environment.prototype); +Environment.call(exports);