merged from ethereum again

This commit is contained in:
Fabian Vogelsteller 2015-03-10 17:09:06 +01:00
commit 27d54218a9
4 changed files with 71 additions and 33 deletions

49
dist/ethereum.js vendored
View File

@ -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
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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
};