2014-03-10 13:47:52 -07:00
|
|
|
/*
|
|
|
|
One way to require files is this simple way:
|
|
|
|
module.exports.Address = require('./Address');
|
2014-03-08 13:42:08 -08:00
|
|
|
|
2014-03-10 13:47:52 -07:00
|
|
|
However, that will load all classes in memory even if they are not used.
|
|
|
|
Instead, we can set the 'get' property of each class to only require them when
|
|
|
|
they are accessed, saving memory if they are not used in a given project.
|
|
|
|
*/
|
|
|
|
var requireWhenAccessed = function(name, file) {
|
|
|
|
Object.defineProperty(module.exports, name, {get: function() {return require(file)}});
|
|
|
|
};
|
2014-03-08 13:42:08 -08:00
|
|
|
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('bignum', 'bignum');
|
|
|
|
requireWhenAccessed('base58', 'base58-native');
|
2014-03-26 08:00:03 -07:00
|
|
|
requireWhenAccessed('bufferput', 'bufferput');
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('buffertools', 'buffertools');
|
2014-04-10 14:52:13 -07:00
|
|
|
requireWhenAccessed('Buffers.monkey', './Buffers.monkey');
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('config', './config');
|
|
|
|
requireWhenAccessed('const', './const');
|
|
|
|
requireWhenAccessed('Deserialize', './Deserialize');
|
|
|
|
requireWhenAccessed('log', './util/log');
|
|
|
|
requireWhenAccessed('networks', './networks');
|
|
|
|
requireWhenAccessed('util', './util/util');
|
|
|
|
requireWhenAccessed('EncodedData', './util/EncodedData');
|
|
|
|
requireWhenAccessed('VersionedData', './util/VersionedData');
|
2014-03-21 08:50:19 -07:00
|
|
|
requireWhenAccessed('BinaryParser', './util/BinaryParser');
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('Address', './Address');
|
2014-03-22 12:23:40 -07:00
|
|
|
requireWhenAccessed('BIP32', './BIP32');
|
2014-03-28 15:07:23 -07:00
|
|
|
requireWhenAccessed('Point', './Point');
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('Opcode', './Opcode');
|
|
|
|
requireWhenAccessed('Script', './Script');
|
|
|
|
requireWhenAccessed('Transaction', './Transaction');
|
2014-03-28 17:17:34 -07:00
|
|
|
requireWhenAccessed('TransactionBuilder', './TransactionBuilder');
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('Connection', './Connection');
|
|
|
|
requireWhenAccessed('Peer', './Peer');
|
|
|
|
requireWhenAccessed('Block', './Block');
|
|
|
|
requireWhenAccessed('ScriptInterpreter', './ScriptInterpreter');
|
|
|
|
requireWhenAccessed('Bloom', './Bloom');
|
2014-03-13 10:31:02 -07:00
|
|
|
requireWhenAccessed('Key', './Key');
|
2014-03-13 10:59:04 -07:00
|
|
|
Object.defineProperty(module.exports, 'KeyModule', {get: function() {
|
|
|
|
console.log('KeyModule is deprecated.');
|
|
|
|
return require('bindings')('KeyModule');
|
|
|
|
}});
|
2014-03-10 13:47:52 -07:00
|
|
|
requireWhenAccessed('SINKey', './SINKey');
|
|
|
|
requireWhenAccessed('SIN', './SIN');
|
|
|
|
requireWhenAccessed('PrivateKey', './PrivateKey');
|
|
|
|
requireWhenAccessed('RpcClient', './RpcClient');
|
|
|
|
requireWhenAccessed('Wallet', './Wallet');
|
|
|
|
requireWhenAccessed('WalletKey', './WalletKey');
|
2014-03-11 20:11:12 -07:00
|
|
|
requireWhenAccessed('PeerManager', './PeerManager');
|
2014-02-20 13:59:41 -08:00
|
|
|
module.exports.Buffer = Buffer;
|
2014-02-04 10:26:58 -08:00
|
|
|
|
|
|
|
if (typeof process.versions === 'undefined') {
|
2014-03-08 13:42:08 -08:00
|
|
|
// Browser specific
|
2014-02-04 10:26:58 -08:00
|
|
|
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});
|
2014-03-08 13:42:08 -08:00
|
|
|
}
|
2014-02-04 10:26:58 -08:00
|
|
|
|