Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "utils/utils"

Index

Variables

Const MAX_DECIMAL_PLACES

MAX_DECIMAL_PLACES: 12 = 12

Const setTimeoutPromise

setTimeoutPromise: __promisify__ = promisify(setTimeout)

A promisified wrapper for the NodeJS setTimeout method.

Functions

Const base64ToHex

  • base64ToHex(b64: string): string

Const checkDecimalPlaces

  • checkDecimalPlaces(digits: number): boolean
  • Returns true if number has more than MAX_DECIMAL_PLACES, false otherwise.

    Parameters

    • digits: number

    Returns boolean

Const convertKvpArrayToKvps

  • convertKvpArrayToKvps<T>(kvpArray: [string, T][]): {}
  • Converts an array of key value pair arrays into an object with the key value pairs.

    Type parameters

    • T

    Parameters

    • kvpArray: [string, T][]

    Returns {}

    • [key: string]: T

Const deepMerge

  • deepMerge(target: any, ...sources: any[]): object
  • Recursively merge properties from different sources into a target object, overriding any existing properties.

    Parameters

    • target: any

      the destination object to merge into.

    • Rest ...sources: any[]

      the sources objects to copy from.

    Returns object

Const derivePairId

  • derivePairId(pair: Pair): string
  • Convert a pair's base currency and quote currency to a ticker symbol pair id.

    Parameters

    Returns string

Const getDefaultBackupDir

  • getDefaultBackupDir(): string

Const getExternalIp

  • getExternalIp(): Promise<string>

Const getPublicMethods

  • getPublicMethods(obj: any): any
  • Get all methods from an object whose name doesn't start with an underscore.

    Parameters

    • obj: any

    Returns any

Const getTsString

  • getTsString(dateFormat?: undefined | string): string
  • Get the current date in the given dateFormat, if not provided formats with YYYY-MM-DD hh:mm:ss.sss.

    Parameters

    • Optional dateFormat: undefined | string

    Returns string

Const groupBy

  • groupBy(arr: object[], keyGetter: (item: any) => string | number): any
  • Parameters

    • arr: object[]
    • keyGetter: (item: any) => string | number
        • (item: any): string | number
        • Parameters

          • item: any

          Returns string | number

    Returns any

Const hexToUint8Array

  • hexToUint8Array(hex: string): Uint8Array

Const isEmptyObject

  • isEmptyObject(val: any): boolean
  • Check whether a variable is an empty object

    Parameters

    • val: any

    Returns boolean

Const isObject

  • isObject(val: any): boolean
  • Check whether a variable is a non-array object

    Parameters

    • val: any

    Returns boolean

Const isPlainObject

  • isPlainObject(obj: any): boolean
  • 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

    Parameters

    • obj: any

    Returns boolean

Const ms

  • ms(): number

parseResponseBody

  • parseResponseBody<T>(res: IncomingMessage): Promise<T>
  • A utility function to parse the payload from an http response.

    Type parameters

    • T

    Parameters

    • res: IncomingMessage

    Returns Promise<T>

Const removeUndefinedProps

  • removeUndefinedProps<T>(typedObj: T): T

Const setObjectToMap

  • setObjectToMap(obj: any, map: { set: (key: string, value: any) => any }): void
  • Parameters

    • obj: any
    • map: { set: (key: string, value: any) => any }
      • set: (key: string, value: any) => any
          • (key: string, value: any): any
          • Parameters

            • key: string
            • value: any

            Returns any

    Returns void

Const sortOrders

  • sortOrders<T>(orders: T[], isBuy: boolean): T[]

Const toEip55Address

  • toEip55Address(address: string): 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'

    Parameters

    • address: string

    Returns string

Const uint8ArrayToHex

  • uint8ArrayToHex(uint8: Uint8Array): string

Generated using TypeDoc