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
21
decimal.js
21
decimal.js
@ -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
2
decimal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user