UNPKG

@aeternity/aepp-sdk

Version:

SDK for the æternity blockchain

48 lines (42 loc) 1.36 kB
import { Buffer as _Buffer } from "buffer"; import { RestError } from '@azure/core-rest-pipeline'; export const pause = async duration => new Promise(resolve => { setTimeout(resolve, duration); }); export const mapObject = (object, fn) => Object.fromEntries(Object.entries(object).map(fn)); // remove after dropping webpack4 support const isWebpack4Buffer = (() => { try { _Buffer.concat([Uint8Array.from([])]); return false; } catch (error) { return true; } })(); export const concatBuffers = isWebpack4Buffer ? (list, totalLength) => _Buffer.concat(list.map(el => _Buffer.from(el)), totalLength) : _Buffer.concat; /** * Object key type guard * @param key - Maybe object key * @param object - Object */ export function isKeyOfObject(key, object) { return key in object; } /** * Array item type guard * @param item - Maybe array item * @param array - Array */ export function isItemOfArray(item, array) { return array.includes(item); } export function isAccountNotFoundError(error) { return error instanceof RestError && error.statusCode === 404 && error.message.includes('Account not found'); } // based on https://stackoverflow.com/a/50375286 // based on https://stackoverflow.com/a/61108377 export function ensureError(error) { if (error instanceof Error) return; throw error; } //# sourceMappingURL=other.js.map