Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

POOL

POOL: BufferPool = new BufferPool(4096)

crypto

crypto: "crypto" = require('crypto')

Various utilities used across this library.

util

util: "util" = require('util')

Functions

BufferPool

  • BufferPool(len: any): void
  • Simple buffer pool to avoid allocating many small buffers.

    This provides significant speedups in recent versions of node (6+).

    Parameters

    • len: any

    Returns void

Lcg

  • Lcg(seed: any): void

OrderedQueue

  • OrderedQueue(): void
  • Ordered queue which returns items consecutively.

    This is actually a heap by index, with the added requirements that elements can only be retrieved consecutively.

    Returns void

Tap

  • Tap(buf: any, pos: any): void
  • A tap is a buffer which remembers what has been already read.

    It is optimized for performance, at the cost of failing silently when overflowing the buffer. This is a purposeful trade-off given the expected rarity of this case and the large performance hit necessary to enforce validity. See isValid below for more information.

    Parameters

    • buf: any
    • pos: any

    Returns void

abstractFunction

  • abstractFunction(): void

addDeprecatedGetters

  • addDeprecatedGetters(obj: any, props: any): void

bufferFrom

  • bufferFrom(data: string | any[], enc: string): Buffer
  • Create a new buffer with the input contents.

    Parameters

    • data: string | any[]

      The buffer's data.

    • enc: string

      Encoding, used if data is a string.

    Returns Buffer

capitalize

  • capitalize(s: string): string

compare

  • compare(n1: number, n2: number): 0 | 1 | -1
  • Compare two numbers.

    Parameters

    • n1: number

      The first one.

    • n2: number

      The second one.

    Returns 0 | 1 | -1

copyOwnProperties

  • copyOwnProperties(src: any, dst: any, overwrite: boolean): any
  • Copy properties from one object to another.

    Parameters

    • src: any

      The source object.

    • dst: any

      The destination object.

    • overwrite: boolean

      Whether to overwrite existing destination properties. Defaults to false.

    Returns any

getHash

  • getHash(str: string, algorithm: string): string | Buffer
  • Compute a string's hash.

    Parameters

    • str: string

      The string to hash.

    • algorithm: string

      The algorithm used. Defaults to MD5.

    Returns string | Buffer

getOption

  • getOption(opts: any, key: string, def: any[]): any
  • Get option or default if undefined.

    Parameters

    • opts: any

      Options.

    • key: string

      Name of the option.

    • def: any[]

      Default value.

      This is useful mostly for true-ish defaults and false-ish values (where the usual || idiom breaks down).

    Returns any

hasDuplicates

  • hasDuplicates(arr: any[], fn: Function): boolean
  • Check whether an array has duplicates.

    Parameters

    • arr: any[]

      The array.

    • fn: Function

      Optional function to apply to each element.

    Returns boolean

invert

  • invert(buf: Buffer, len: number): void
  • Invert all bits in a buffer.

    Parameters

    • buf: Buffer

      Non-empty buffer to invert.

    • len: number

      Buffer length (must be positive).

    Returns void

jsonEnd

  • jsonEnd(str: string, pos: number): number
  • Returns offset in the string of the end of JSON object (-1 if past the end).

    To keep the implementation simple, this function isn't a JSON validator. It will gladly return a result for invalid JSON (which is OK since that will be promptly rejected by the JSON parser). What matters is that it is guaranteed to return the correct end when presented with valid JSON.

    Parameters

    • str: string

      Input string containing serialized JSON..

    • pos: number

      Starting position.

    Returns number

newBuffer

  • newBuffer(size: number): Buffer

objectValues

  • objectValues(obj: any): any[]
  • Convert map to array of values (polyfill for Object.values).

    Parameters

    • obj: any

      Map.

    Returns any[]

singleIndexOf

  • singleIndexOf(arr: any[], v: any): number
  • Find index of value in array.

    Parameters

    • arr: any[]

      Can also be a false-ish value.

    • v: any

      Value to find.

      Returns -1 if not found, -2 if found multiple times.

    Returns number

toMap

  • toMap(arr: any[], fn: Function): object
  • Convert array to map.

    Parameters

    • arr: any[]

      Elements.

    • fn: Function

      Function returning an element's key.

    Returns object

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc