Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "func/lookup"

Index

Functions

Const lookup1d

  • lookup1d<T>(src: T[]): (Anonymous function)
  • Returns function accepting a single index arg used to lookup value in given array. No bounds checks are done.

    example
    [...map(lookup1d([10, 20, 30]), [2,0,1])]
    // [ 30, 10, 20 ]

    Type parameters

    • T

    Parameters

    • src: T[]

      source data

    Returns (Anonymous function)

Const lookup2d

  • lookup2d<T>(src: T[], width: number): (Anonymous function)
  • Returns function accepting a single [x, y] index tuple, used to lookup value in given array. Useful for transducers processing 2D data.

    remarks

    The source data MUST be in row major linearized format, i.e. 1D representation of 2D data (pixel buffer). No bounds checks are done.

    example
    [...map(lookup2d([...range(9)], 3), range2d(2, -1, 0, 3))]
    // [ 2, 1, 0, 5, 4, 3, 8, 7, 6 ]

    Type parameters

    • T

    Parameters

    • src: T[]

      source data

    • width: number

      number of items along X (columns)

    Returns (Anonymous function)

Const lookup3d

  • lookup3d<T>(src: T[], width: number, height: number): (Anonymous function)
  • Same as lookup2d, but for 3D data. The index ordering of the source data MUST be in Z, Y, X order (i.e. a stack of row major 2D slices). No bounds checks are done.

    Type parameters

    • T

    Parameters

    • src: T[]

      source data

    • width: number

      number of items along X (columns)

    • height: number

      number of items along Y (rows)

    Returns (Anonymous function)

Generated using TypeDoc