@injectivelabs/utils
Advanced tools
Comparing version 1.0.73 to 1.0.74
import { ComposerResponse } from '@injectivelabs/ts-types'; | ||
export declare const sleep: (timeout: number) => Promise<void>; | ||
/** | ||
* When we want to execute the promises in batch | ||
*/ | ||
export declare const awaitAll: <T, S>(array: T[], callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
/** | ||
* When we want to execute the promises one by one | ||
* and not all in batch as with await Promise.all() | ||
*/ | ||
export declare const awaitForAll: <T, S>(array: T[], callback: (item: T) => Promise<S>) => Promise<S[]>; | ||
export declare const isServerSide: () => boolean; | ||
@@ -5,0 +13,0 @@ export declare const mapMultipleComposerResponseMessages: <T, R>(messages: ComposerResponse<T, R>[]) => { |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDefaultStdFee = exports.getStdFee = exports.getStdFeeForToken = exports.mapMultipleComposerResponseMessages = exports.isServerSide = exports.awaitAll = exports.sleep = void 0; | ||
exports.getDefaultStdFee = exports.getStdFee = exports.getStdFeeForToken = exports.mapMultipleComposerResponseMessages = exports.isServerSide = exports.awaitForAll = exports.awaitAll = exports.sleep = void 0; | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
@@ -23,4 +23,19 @@ const constants_1 = require("./constants"); | ||
exports.sleep = sleep; | ||
/** | ||
* When we want to execute the promises in batch | ||
*/ | ||
const awaitAll = (array, callback) => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.all(array.map((item) => __awaiter(void 0, void 0, void 0, function* () { return yield callback(item); }))); }); | ||
exports.awaitAll = awaitAll; | ||
/** | ||
* When we want to execute the promises one by one | ||
* and not all in batch as with await Promise.all() | ||
*/ | ||
const awaitForAll = (array, callback) => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = []; | ||
for (let i = 0; i < array.length; i += 1) { | ||
result.push(yield callback(array[i])); | ||
} | ||
return result; | ||
}); | ||
exports.awaitForAll = awaitForAll; | ||
const isServerSide = () => typeof window === 'undefined'; | ||
@@ -27,0 +42,0 @@ exports.isServerSide = isServerSide; |
{ | ||
"name": "@injectivelabs/utils", | ||
"description": "List of utils and helper functions that can be reused throughout Injective's projects.", | ||
"version": "1.0.73", | ||
"version": "1.0.74", | ||
"author": { | ||
@@ -44,3 +44,3 @@ "name": "Bojan Angjelkoski", | ||
}, | ||
"gitHead": "3b7401ce10ce1f5a32de622cc3ad0588ec645150" | ||
"gitHead": "b2d4b53a06ed3c735f267a75e1b62cf89ecba525" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74485
813