mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2024-10-27 20:34:12 +00:00
try catch crypto require
This commit is contained in:
parent
e02587a173
commit
aed581dfb6
23
decimal.js
23
decimal.js
@ -12,13 +12,14 @@
|
||||
*/
|
||||
|
||||
|
||||
var convertBase, crypto, DecimalConstructor, noConflict,
|
||||
toString = Object.prototype.toString,
|
||||
outOfRange,
|
||||
id = 0,
|
||||
var convertBase, DecimalConstructor, noConflict,
|
||||
crypto = global['crypto'],
|
||||
external = true,
|
||||
id = 0,
|
||||
mathfloor = Math.floor,
|
||||
mathpow = Math.pow,
|
||||
outOfRange,
|
||||
toString = Object.prototype.toString,
|
||||
BASE = 1e7,
|
||||
LOGBASE = 7,
|
||||
NUMERALS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
|
||||
@ -3950,24 +3951,24 @@
|
||||
|
||||
// AMD.
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
crypto = global['crypto'];
|
||||
|
||||
define(function () {
|
||||
|
||||
return DecimalConstructor;
|
||||
});
|
||||
|
||||
// Node and other CommonJS-like environments that support module.exports.
|
||||
} else if ( typeof module != 'undefined' && module && module.exports ) {
|
||||
// Node and other environments that support module.exports.
|
||||
} else if ( typeof module != 'undefined' && module.exports ) {
|
||||
module.exports = DecimalConstructor;
|
||||
|
||||
if ( typeof require == 'function' ) {
|
||||
crypto = require('crypto');
|
||||
if ( !crypto ) {
|
||||
|
||||
try {
|
||||
crypto = require('crypto');
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Browser.
|
||||
} else {
|
||||
crypto = global['crypto'];
|
||||
noConflict = global['Decimal'];
|
||||
|
||||
DecimalConstructor['noConflict'] = function () {
|
||||
|
2
decimal.min.js
vendored
2
decimal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user