From be4a228aee50be4a63b65f2afbd43b0f89031388 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 27 Feb 2014 23:10:35 -0300 Subject: [PATCH] prevent requiring bitcoinjs-lib each time --- examples/example.html | 8 ++++++++ util/util.js | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/example.html b/examples/example.html index c971798..6f79794 100644 --- a/examples/example.html +++ b/examples/example.html @@ -7,6 +7,7 @@
+ diff --git a/util/util.js b/util/util.js index 1cbdf83..af8b094 100644 --- a/util/util.js +++ b/util/util.js @@ -4,6 +4,12 @@ var bignum = require('bignum'); var Binary = require('binary'); var Put = require('bufferput'); var buffertools = require('buffertools'); +var bjs; +if (!process.versions) { + // browser version + bjs = require('../browser/bitcoinjs-lib.js'); +} + var sha256 = exports.sha256 = function (data) { return new Buffer(crypto.createHash('sha256').update(data).digest('binary'), 'binary'); @@ -11,8 +17,6 @@ var sha256 = exports.sha256 = function (data) { var ripe160 = exports.ripe160 = function (data) { if (!process.versions) { - // browser version - var bjs = require('../browser/bitcoinjs-lib.js'); var RIPEMD160 = bjs.RIPEMD160; var WordArray = bjs.WordArray; data = data.toString();