Socket
Socket
Sign inDemoInstall

table-parser-base

Package Overview
Dependencies
18
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    table-parser-base

Utilities for table parser packages


Version published
Weekly downloads
1.4K
increased by11.62%
Maintainers
1
Install size
7.48 MB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 06 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc