table-parser-base
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Table Parser Base

Utilities for table parser packages

Usage

Convert an ArrayTable to an ObjectTable

const { createObjectTable } = await import('table-parser-base')

const arrayTable = {
  headers: ['id', 'name', 'email'],
  rows: [
    [1, 'John Doe', 'john-doe@gmail.com'],
    [2, 'Peter Smith', 'petersmith22@outlook.com'],
    [3, 'Julia Jones', 'jjones778@gmail.com']
  ]
}

const objectTable = createObjectTable(arrayTable)
for await (const item of objectTable) {
  console.log(item)
}

Output:

{ id: 1, name: 'John Doe', email: 'john-doe@gmail.com' }
{ id: 2, name: 'Peter Smith', email: 'petersmith22@outlook.com' }
{ id: 3, name: 'Julia Jones', email: 'jjones778@gmail.com' }

Convert an ObjectTable to an ArrayTable

const { createArrayTable } = await import('table-parser-base')

const objectTable = [
  { id: 1, name: 'John Doe', email: 'john-doe@gmail.com' },
  { id: 2, name: 'Peter Smith', email: 'petersmith22@outlook.com' },
  { id: 3, name: 'Julia Jones', email: 'jjones778@gmail.com' }
]

const arrayTable = await createArrayTable(objectTable)
console.log(arrayTable)

Output:

{
  headers: [ 'id', 'name', 'email' ],
  rows: [
    [ 1, 'John Doe', 'john-doe@gmail.com' ],
    [ 2, 'Peter Smith', 'petersmith22@outlook.com' ],
    [ 3, 'Julia Jones', 'jjones778@gmail.com' ]
  ]
}

License

MIT © Hoàng Văn Khải

/table-parser-base/

    Package Sidebar

    Install

    npm i table-parser-base

    Weekly Downloads

    793

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    8.08 kB

    Total Files

    5

    Last publish

    Collaborators

    • khai96_