1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-09-28 22:40:48 +00:00

try catch crypto require

This commit is contained in:
Michael Mclaughlin 2014-06-08 23:08:33 +01:00
parent e02587a173
commit aed581dfb6
2 changed files with 13 additions and 12 deletions

View File

@ -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 ) {
try {
crypto = require('crypto'); 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