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

table2array

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table2array

Converts HTML table to Javascript array

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

table2array

Node.js utility to convert HTML table to Javascript array.

Installation

npm install table2array

Usage

import table2array from 'table2array'

const table = `<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Chester</td>
      <td>41</td>
    </tr>
    <tr>
      <td>Steve</td>
      <td>56</td>
    </tr>
  </tbody>
</table>`

const array = table2array(playlist)

console.log(array)

Output:

[
  ["Name", "Age"],
  ["Chester", "41"],
  ["Steve", "56"]
]

Examples

Table with rowspan

ParentChild
MarrySue
Steve
Tom
[
  ["Parent", "Child"],
  ["Marry", "Sue"],
  ["Marry", "Steve"],
  ["Marry", "Tom"]
]

Table with colspan

MondayTuesdayWednesdayThursdayFridaySaturdaySunday
8:00 - 17:0010:00 - 13:00Closed
[
  ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  [
    "8:00 - 17:00",
    "8:00 - 17:00",
    "8:00 - 17:00",
    "8:00 - 17:00",
    "8:00 - 17:00",
    "10:00 - 13:00",
    "Closed"
  ]
]

Complex table

MondayTuesdayWednesdayThursdayFridaySaturdaySunday
Superlift Off-Road AdventuresThe American Car ProspectorFormula One Drift
Lund International Truck and Jeep ShowHooked On DirtCar FilesWorld of Trucks
[
  ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  [
    "Superlift Off-Road Adventures",
    "Superlift Off-Road Adventures",
    "Superlift Off-Road Adventures",
    "Superlift Off-Road Adventures",
    "The American Car Prospector",
    "The American Car Prospector",
    "Formula One Drift"
  ],
  [
    "Lund International Truck and Jeep Show",
    "Hooked On Dirt",
    "Car Files",
    "Car Files",
    "The American Car Prospector",
    "The American Car Prospector",
    "World of Trucks"
  ]
]

Testing

npm test

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

Keywords

FAQs

Package last updated on 26 Nov 2022

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