UNPKG

xud

Version:
84 lines (83 loc) 3.45 kB
/// <reference types="node" /> import http from 'http'; import { Pair, SortableOrder } from '../orderbook/types'; /** * Gets the external IP of the node. */ export declare const getExternalIp: () => Promise<string>; /** * Check whether a variable is a non-array object */ export declare const isObject: (val: any) => boolean; /** * Check whether a variable is an empty object */ export declare const isEmptyObject: (val: any) => boolean; /** Get the current date in the given dateFormat, if not provided formats with `YYYY-MM-DD hh:mm:ss.sss`. */ export declare const getTsString: (dateFormat?: string | undefined) => string; /** * Recursively merge properties from different sources into a target object, overriding any * existing properties. * @param target the destination object to merge into. * @param sources the sources objects to copy from. */ export declare const deepMerge: (target: any, ...sources: any[]) => object; /** * Get all methods from an object whose name doesn't start with an underscore. */ export declare const getPublicMethods: (obj: any) => any; export declare const groupBy: (arr: object[], keyGetter: (item: any) => string | number) => any; /** Returns true if number has more than MAX_DECIMAL_PLACES, false otherwise. */ export declare const checkDecimalPlaces: (digits: number) => boolean; /** * Get current time in unix time (milliseconds). */ export declare const ms: () => number; /** * Convert a pair's base currency and quote currency to a ticker symbol pair id. */ export declare const derivePairId: (pair: Pair) => string; /** * A simplified copy of lodash's isPlainObject; * * A plain object is; * - prototype should be [object Object] * - shouldn't be null * - its type should be 'object' (does extra check because typeof null == object) * * Examples; * isPlainObject(new Foo); => false * isPlainObject([1, 2, 3]); => false * isPlainObject({ 'x': 0, 'y': 0 }); => true * isPlainObject(Object.create(null)); => true */ export declare const isPlainObject: (obj: any) => boolean; /** A promisified wrapper for the NodeJS `setTimeout` method. */ export declare const setTimeoutPromise: typeof setTimeout.__promisify__; export declare const removeUndefinedProps: <T>(typedObj: T) => T; export declare const setObjectToMap: (obj: any, map: { set: (key: string, value: any) => any; }) => void; /** * Converts an array of key value pair arrays into an object with the key value pairs. */ export declare const convertKvpArrayToKvps: <T>(kvpArray: [string, T][]) => { [key: string]: T; }; export declare const sortOrders: <T extends SortableOrder>(orders: T[], isBuy: boolean) => T[]; export declare const base64ToHex: (b64: string) => string; export declare const hexToUint8Array: (hex: string) => Uint8Array; export declare const uint8ArrayToHex: (uint8: Uint8Array) => string; /** * Converts input to EIP55 format. * Prints the ith digit in uppercase if it's a letter and the 4*ith bit of the hash of the lowercase hexadecimal address is 1 * otherwise prints it in lowercase. * Example: '0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359' is converted to '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359' */ export declare const toEip55Address: (address: string) => string; export declare const getDefaultBackupDir: () => string; /** * A utility function to parse the payload from an http response. */ export declare function parseResponseBody<T>(res: http.IncomingMessage): Promise<T>;