@celo/utils
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -5,4 +5,6 @@ /// <reference types="node" /> | ||
export declare const normalizeAddress: (a: string) => string; | ||
export declare const normalizeAddressWith0x: (a: string) => string; | ||
export declare const trimLeading0x: (input: string) => string; | ||
export declare const ensureLeading0x: (input: string) => string; | ||
export declare const isHexString: (imput: string) => boolean; | ||
export declare const hexToBuffer: (input: string) => Buffer; | ||
@@ -9,0 +11,0 @@ export declare const privateKeyToAddress: (privateKey: string) => string; |
@@ -11,6 +11,9 @@ "use strict"; | ||
var ethereumjs_util_1 = require("ethereumjs-util"); | ||
var HEX_REGEX = /^0x[0-9A-F]*$/i; | ||
exports.eqAddress = function (a, b) { return exports.normalizeAddress(a) === exports.normalizeAddress(b); }; | ||
exports.normalizeAddress = function (a) { return exports.trimLeading0x(a).toLowerCase(); }; | ||
exports.normalizeAddressWith0x = function (a) { return exports.ensureLeading0x(a).toLowerCase(); }; | ||
exports.trimLeading0x = function (input) { return (input.startsWith('0x') ? input.slice(2) : input); }; | ||
exports.ensureLeading0x = function (input) { return (input.startsWith('0x') ? input : "0x" + input); }; | ||
exports.isHexString = function (imput) { return HEX_REGEX.test(imput); }; | ||
exports.hexToBuffer = function (input) { return Buffer.from(exports.trimLeading0x(input), 'hex'); }; | ||
@@ -17,0 +20,0 @@ exports.privateKeyToAddress = function (privateKey) { |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.stringToBoolean = function (inputString) { | ||
var lowercasedInput = inputString.toLowerCase(); | ||
var lowercasedInput = inputString.toLowerCase().trim(); | ||
if (lowercasedInput === 'true') { | ||
@@ -17,3 +17,3 @@ return true; | ||
} | ||
throw new Error('Parsing error'); | ||
throw new Error("Unable to parse '" + inputString + "' as boolean"); | ||
}; | ||
@@ -20,0 +20,0 @@ exports.parseInputAmount = function (inputString) { |
@@ -10,6 +10,8 @@ "use strict"; | ||
expect(parsing_1.stringToBoolean('true')).toBe(true); | ||
expect(parsing_1.stringToBoolean(' true ')).toBe(true); | ||
expect(parsing_1.stringToBoolean('false')).toBe(false); | ||
expect(parsing_1.stringToBoolean('False')).toBe(false); | ||
expect(parsing_1.stringToBoolean('True')).toBe(true); | ||
expect(function () { return parsing_1.stringToBoolean('fals'); }).toThrow('Parsing error'); | ||
expect(parsing_1.stringToBoolean(' false ')).toBe(false); | ||
expect(parsing_1.stringToBoolean('FaLse')).toBe(false); | ||
expect(parsing_1.stringToBoolean('TruE')).toBe(true); | ||
expect(function () { return parsing_1.stringToBoolean('fals'); }).toThrow("Unable to parse 'fals' as boolean"); | ||
}); | ||
@@ -16,0 +18,0 @@ test('stringToBigNum()', function () { |
{ | ||
"name": "@celo/utils", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Celo common utils", | ||
@@ -5,0 +5,0 @@ "author": "Celo", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
674884
157
6355
3