Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

table-parser-base

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table-parser-base

Utilities for table parser packages

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 06 Jul 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc