@celo/base
Advanced tools
Comparing version 0.0.4 to 1.0.0-beta
@@ -20,3 +20,8 @@ # Changelog | ||
## Published | ||
### **[0.0.4]** -- 2020-10-30 | ||
Features | ||
- JSON Parsing Utils - [#5091](https://github.com/celo-org/celo-monorepo/pull/5091) | ||
## Published | ||
### **[0.0.3]** -- 2020-09-23 | ||
_Note: Changes before and including 0.0.3 are not documented_ |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
export declare const normalizeAddress: (a: string) => string; | ||
export declare const isNullAddress: (a: string) => boolean; | ||
export declare const normalizeAddressWith0x: (a: string) => string; | ||
@@ -7,0 +8,0 @@ export declare const trimLeading0x: (input: string) => string; |
@@ -9,6 +9,11 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
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.isNullAddress = function (a) { return new bignumber_js_1.default(exports.normalizeAddress(a)).isZero(); }; | ||
exports.normalizeAddressWith0x = function (a) { return exports.ensureLeading0x(a).toLowerCase(); }; | ||
@@ -15,0 +20,0 @@ exports.trimLeading0x = function (input) { return (input.startsWith('0x') ? input.slice(2) : input); }; |
@@ -0,7 +1,8 @@ | ||
import { Logger } from './logger'; | ||
/** Sleep for a number of milliseconds */ | ||
export declare function sleep(ms: number): Promise<void>; | ||
declare type InFunction<T extends any[], U> = (...params: T) => Promise<U>; | ||
export declare const retryAsync: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, params: T, delay?: number) => Promise<U>; | ||
export declare const retryAsyncWithBackOff: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, params: T, delay?: number, factor?: number) => Promise<U>; | ||
export declare const selectiveRetryAsyncWithBackOff: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, dontRetry: string[], params: T, delay?: number, factor?: number) => Promise<U>; | ||
export declare const retryAsync: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, params: T, delay?: number, logger?: Logger | null) => Promise<U>; | ||
export declare const retryAsyncWithBackOff: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, params: T, delay?: number, factor?: number, logger?: Logger | null) => Promise<U>; | ||
export declare const selectiveRetryAsyncWithBackOff: <T extends any[], U>(inFunction: InFunction<T, U>, tries: number, dontRetry: string[], params: T, delay?: number, factor?: number, logger?: Logger | null) => Promise<U>; | ||
/** | ||
@@ -8,0 +9,0 @@ * Map an async function over a list xs with a given concurrency level |
@@ -47,4 +47,5 @@ "use strict"; | ||
// if all the tries fail it raises the last thrown exeption | ||
exports.retryAsync = function (inFunction, tries, params, delay) { | ||
exports.retryAsync = function (inFunction, tries, params, delay, logger) { | ||
if (delay === void 0) { delay = 100; } | ||
if (logger === void 0) { logger = null; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -72,3 +73,5 @@ var saveError, i, error_1; | ||
saveError = error_1; | ||
console.info(TAG + "/@retryAsync, Failed to execute function on try #" + i + ":", error_1); | ||
if (logger) { | ||
logger(TAG + "/@retryAsync, Failed to execute function on try #" + i + ":", error_1); | ||
} | ||
return [3 /*break*/, 6]; | ||
@@ -85,5 +88,6 @@ case 6: | ||
// if all the tries fail it raises the last thrown exeption | ||
exports.retryAsyncWithBackOff = function (inFunction, tries, params, delay, factor) { | ||
exports.retryAsyncWithBackOff = function (inFunction, tries, params, delay, factor, logger) { | ||
if (delay === void 0) { delay = 100; } | ||
if (factor === void 0) { factor = 1.5; } | ||
if (logger === void 0) { logger = null; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -111,3 +115,5 @@ var saveError, i, error_2; | ||
saveError = error_2; | ||
console.info(TAG + "/@retryAsync, Failed to execute function on try #" + i, error_2); | ||
if (logger) { | ||
logger(TAG + "/@retryAsync, Failed to execute function on try #" + i, error_2); | ||
} | ||
return [3 /*break*/, 6]; | ||
@@ -125,5 +131,6 @@ case 6: | ||
// throws automatically on specified errors | ||
exports.selectiveRetryAsyncWithBackOff = function (inFunction, tries, dontRetry, params, delay, factor) { | ||
exports.selectiveRetryAsyncWithBackOff = function (inFunction, tries, dontRetry, params, delay, factor, logger) { | ||
if (delay === void 0) { delay = 100; } | ||
if (factor === void 0) { factor = 1.5; } | ||
if (logger === void 0) { logger = null; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -151,3 +158,5 @@ var saveError, i, error_3; | ||
saveError = error_3; | ||
console.info(TAG + "/@retryAsync, Failed to execute function on try #" + i, error_3); | ||
if (logger) { | ||
logger(TAG + "/@retryAsync, Failed to execute function on try #" + i, error_3); | ||
} | ||
return [3 /*break*/, 5]; | ||
@@ -154,0 +163,0 @@ case 5: |
export declare function zip<A, B, C>(fn: (a: A, b: B) => C, as: A[], bs: B[]): C[]; | ||
export declare function zip3<A, B, C>(as: A[], bs: B[], cs: C[]): [A, B, C][]; | ||
export declare function zeroRange(to: number): number[]; | ||
export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue; | ||
@@ -4,0 +5,0 @@ export declare function intersection<T>(arrays: T[][]): T[]; |
@@ -29,2 +29,6 @@ "use strict"; | ||
exports.zip3 = zip3; | ||
function zeroRange(to) { | ||
return Array.from(Array(to).keys()); | ||
} | ||
exports.zeroRange = zeroRange; | ||
// https://stackoverflow.com/questions/43118692/typescript-filter-out-nulls-from-an-array | ||
@@ -31,0 +35,0 @@ function notEmpty(value) { |
{ | ||
"name": "@celo/base", | ||
"version": "0.0.4", | ||
"version": "1.0.0-beta", | ||
"description": "Celo base common utils, no dependencies", | ||
@@ -26,4 +26,5 @@ "author": "Celo", | ||
"bignumber.js": "^9.0.0", | ||
"elliptic": "^6.5.3" | ||
"elliptic": "^6.5.3", | ||
"web3-utils": "1.3.0" | ||
} | ||
} |
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
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
180190
2750
0
5