mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
merged from ethereum again
This commit is contained in:
commit
27d54218a9
49
dist/ethereum.js
vendored
49
dist/ethereum.js
vendored
@ -832,30 +832,25 @@ var fromDecimal = function (value) {
|
||||
* @return {String}
|
||||
*/
|
||||
var toHex = function (val) {
|
||||
/*jshint maxcomplexity:5 */
|
||||
|
||||
if(typeof val === 'boolean')
|
||||
if(isBoolean(val))
|
||||
return val;
|
||||
|
||||
if(isBigNumber(val))
|
||||
return fromDecimal(val);
|
||||
|
||||
if(typeof val === 'object')
|
||||
if(isObject(val))
|
||||
return fromAscii(JSON.stringify(val));
|
||||
|
||||
if(isString(val) && val.indexOf('0x') === 0)
|
||||
return val;
|
||||
// if its a negative number, pass it through fromDecimal
|
||||
if(isString(val) && val.indexOf('-0x') === 0)
|
||||
return fromDecimal(val);
|
||||
if (isString(val)) {
|
||||
if (val.indexOf('-0x') === 0)
|
||||
return fromDecimal(val);
|
||||
else if (!isFinite(val))
|
||||
return fromAscii(val);
|
||||
}
|
||||
|
||||
if(isString(val) && !isFinite(val))
|
||||
return fromAscii(val);
|
||||
|
||||
if(isFinite(val))
|
||||
return fromDecimal(val);
|
||||
|
||||
return val;
|
||||
return fromDecimal(val);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1012,6 +1007,28 @@ var isFunction = function (object) {
|
||||
return typeof object === 'function';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if object is Objet, otherwise false
|
||||
*
|
||||
* @method isObject
|
||||
* @param {Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isObject = function (object) {
|
||||
return typeof object === 'object';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if object is boolean, otherwise false
|
||||
*
|
||||
* @method isBoolean
|
||||
* @param {Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isBoolean = function (object) {
|
||||
return typeof object === 'boolean';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
findIndex: findIndex,
|
||||
toHex: toHex,
|
||||
@ -1030,7 +1047,9 @@ module.exports = {
|
||||
isBigNumber: isBigNumber,
|
||||
isAddress: isAddress,
|
||||
isFunction: isFunction,
|
||||
isString: isString
|
||||
isString: isString,
|
||||
isObject: isObject,
|
||||
isBoolean: isBoolean
|
||||
};
|
||||
|
||||
|
||||
|
4
dist/ethereum.js.map
vendored
4
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -214,30 +214,25 @@ var fromDecimal = function (value) {
|
||||
* @return {String}
|
||||
*/
|
||||
var toHex = function (val) {
|
||||
/*jshint maxcomplexity:5 */
|
||||
|
||||
if(typeof val === 'boolean')
|
||||
if(isBoolean(val))
|
||||
return val;
|
||||
|
||||
if(isBigNumber(val))
|
||||
return fromDecimal(val);
|
||||
|
||||
if(typeof val === 'object')
|
||||
if(isObject(val))
|
||||
return fromAscii(JSON.stringify(val));
|
||||
|
||||
if(isString(val) && val.indexOf('0x') === 0)
|
||||
return val;
|
||||
// if its a negative number, pass it through fromDecimal
|
||||
if(isString(val) && val.indexOf('-0x') === 0)
|
||||
return fromDecimal(val);
|
||||
if (isString(val)) {
|
||||
if (val.indexOf('-0x') === 0)
|
||||
return fromDecimal(val);
|
||||
else if (!isFinite(val))
|
||||
return fromAscii(val);
|
||||
}
|
||||
|
||||
if(isString(val) && !isFinite(val))
|
||||
return fromAscii(val);
|
||||
|
||||
if(isFinite(val))
|
||||
return fromDecimal(val);
|
||||
|
||||
return val;
|
||||
return fromDecimal(val);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -394,6 +389,28 @@ var isFunction = function (object) {
|
||||
return typeof object === 'function';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if object is Objet, otherwise false
|
||||
*
|
||||
* @method isObject
|
||||
* @param {Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isObject = function (object) {
|
||||
return typeof object === 'object';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if object is boolean, otherwise false
|
||||
*
|
||||
* @method isBoolean
|
||||
* @param {Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isBoolean = function (object) {
|
||||
return typeof object === 'boolean';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
findIndex: findIndex,
|
||||
toHex: toHex,
|
||||
@ -412,6 +429,8 @@ module.exports = {
|
||||
isBigNumber: isBigNumber,
|
||||
isAddress: isAddress,
|
||||
isFunction: isFunction,
|
||||
isString: isString
|
||||
isString: isString,
|
||||
isObject: isObject,
|
||||
isBoolean: isBoolean
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user