Socket
Socket
Sign inDemoInstall

@celo/utils

Package Overview
Dependencies
Maintainers
12
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@celo/utils - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

lib/src/address.d.ts

2

lib/address.d.ts

@@ -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) {

4

lib/parsing.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc