try catch crypto require

pull/7/merge
Michael Mclaughlin 10 years ago
parent e02587a173
commit aed581dfb6

@ -12,13 +12,14 @@
*/ */
var convertBase, crypto, DecimalConstructor, noConflict, var convertBase, DecimalConstructor, noConflict,
toString = Object.prototype.toString, crypto = global['crypto'],
outOfRange,
id = 0,
external = true, external = true,
id = 0,
mathfloor = Math.floor, mathfloor = Math.floor,
mathpow = Math.pow, mathpow = Math.pow,
outOfRange,
toString = Object.prototype.toString,
BASE = 1e7, BASE = 1e7,
LOGBASE = 7, LOGBASE = 7,
NUMERALS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_', NUMERALS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
@ -3950,24 +3951,24 @@
// AMD. // AMD.
if ( typeof define == 'function' && define.amd ) { if ( typeof define == 'function' && define.amd ) {
crypto = global['crypto'];
define(function () { define(function () {
return DecimalConstructor; return DecimalConstructor;
}); });
// Node and other CommonJS-like environments that support module.exports. // Node and other environments that support module.exports.
} else if ( typeof module != 'undefined' && module && module.exports ) { } else if ( typeof module != 'undefined' && module.exports ) {
module.exports = DecimalConstructor; module.exports = DecimalConstructor;
if ( typeof require == 'function' ) { if ( !crypto ) {
crypto = require('crypto');
try {
crypto = require('crypto');
} catch (e) {}
} }
// Browser. // Browser.
} else { } else {
crypto = global['crypto'];
noConflict = global['Decimal']; noConflict = global['Decimal'];
DecimalConstructor['noConflict'] = function () { DecimalConstructor['noConflict'] = function () {

2
decimal.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save