ethjs-util
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -0,1 +1,6 @@ | ||
# 0.0.2 -- added isHexString and getKeys | ||
1. added `isHexString` method | ||
2. added `getKeys` method util | ||
# 0.0.1 -- ethjs-util | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "ethjs-util", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A simple set of Ethereum JS utilties.", | ||
@@ -39,5 +39,5 @@ "main": "./src/index.js", | ||
"bugs": { | ||
"url": "https://github.com/silentcicero/ethjs-format/issues" | ||
"url": "https://github.com/silentcicero/ethjs-util/issues" | ||
}, | ||
"homepage": "https://github.com/silentcicero/ethjs-format#readme", | ||
"homepage": "https://github.com/silentcicero/ethjs-util#readme", | ||
"devDependencies": { | ||
@@ -44,0 +44,0 @@ "chai": "^3.5.0", |
@@ -73,3 +73,3 @@ ## ethjs-util | ||
Please help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBigNumberB linting standard. Please read more about contributing to `ethjs-util` in the `CONTRIBUTING.md`. | ||
Please help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy. | ||
@@ -76,0 +76,0 @@ <!-- |
@@ -217,2 +217,29 @@ const assert = require('assert'); | ||
// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3] | ||
function getKeys(params, key, allowEmpty) { | ||
if (!Array.isArray(params)) { throw new Error('invalid params'); } | ||
var result = []; // eslint-disable-line | ||
for (var i = 0; i < params.length; i++) { // eslint-disable-line | ||
var value = params[i][key]; // eslint-disable-line | ||
if (allowEmpty && !value) { | ||
value = ''; | ||
} else if (typeof(value) !== 'string') { | ||
throw new Error('invalid abi'); | ||
} | ||
result.push(value); | ||
} | ||
return result; | ||
} | ||
function isHexString(value, length) { | ||
if (typeof(value) !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) { | ||
return false; | ||
} | ||
if (length && value.length !== 2 + 2 * length) { return false; } | ||
return true; | ||
} | ||
module.exports = { | ||
@@ -231,2 +258,4 @@ arrayContainsArray, | ||
toUtf8, | ||
getKeys, | ||
isHexString, | ||
}; |
@@ -17,2 +17,4 @@ const util = require('../index.js'); | ||
'toAscii', | ||
'getKeys', | ||
'isHexString', | ||
'toUtf8']; | ||
@@ -19,0 +21,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18432
246