Options
All
  • Public
  • Public/Protected
  • All
Menu

tablegun - v0.3.0

Index

Functions

buildDataSet

  • buildDataSet(data: readonly any[], properties: string[]): Record<string, any[]>
  • Dataset builder

    A classic table stores data as rows. The function flips the table and returns a dictionary that stores data in columns

    const data = [
      { name: 'Sam', age: 20 },
      { name: 'John', age: 22 }
    ]
    
    buildDataSet(data, [ 'name', 'age' ])
    // > {
    //   name: [ 'Sam', 'John' ],
    //   age: [ 20, 22 ]
    // }
    

    Parameters

    • data: readonly any[]

      List of data

    • properties: string[]

      List of properties that will be used as keys in the result

    Returns Record<string, any[]>

buildItemByIndex

  • buildItemByIndex(index: number, dataset: Record<string, any[]>): Record<string, any>
  • Build entity by index

    Build entity by index from dataset

    buildItemByIndex(0, {
      name: [ 'Sam', 'John' ],
      age: [ 20, 22 ]
    })
    // > {
    //   name: 'Sam',
    //   age: 20
    // }
    
    see

    buildDataSet

    Parameters

    • index: number

      Array index

    • dataset: Record<string, any[]>

      Dataset

    Returns Record<string, any>

    Entity

buildSeries

  • buildSeries(takeValue: (data: Record<string, any>) => any, data: readonly Record<string, any>[]): any[]
  • Parameters

    • takeValue: (data: Record<string, any>) => any
        • (data: Record<string, any>): any
        • Parameters

          • data: Record<string, any>

          Returns any

    • data: readonly Record<string, any>[]

    Returns any[]

Generated using TypeDoc