table-parser is a Node.js library designed to parse tabular, shell-style output into structured JavaScript objects. Its primary function, `parse`, takes a string of data (like `ps` command output) and converts it into an array of objects, where each object represents a row and keys correspond to column headers. The current stable version is 1.0.1, released in 2018, and the project appears to be abandoned with no further updates or releases since then. This library differentiates itself through its minimalist approach and specific handling of quoted strings within a row; for example, a string like "C:\Program Files\..." will be treated as a single value, with the initial double quote removed. However, subsequent double quotes within a value are preserved. By default, values are split into arrays by whitespace unless enclosed in quotes. Due to its age, `table-parser` lacks support for modern JavaScript module systems like ESM and may not be compatible with newer Node.js versions or environments without CommonJS support. It offers a simple, unopinionated way to process predictable shell outputs, but users should be aware of its lack of ongoing maintenance and potential limitations for complex parsing needs or evolving data formats.
npm install table-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a multi-line string resembling `ps` command output into an array of JavaScript objects.
For new projects, consider using a more actively maintained parsing library. If you must use `table-parser`, thoroughly test its behavior in your target environment and be aware of potential limitations.
In an ESM project, you must use a compatibility wrapper like `createRequire` from the `module` built-in module: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Parser = require('table-parser');`Always inspect the `parsedData` output carefully to understand how your specific input strings are being processed. Be prepared to implement post-processing logic to adjust the parsed values if they don't meet your exact requirements.
Ensure you are correctly requiring the package and calling `parse` as a method of the returned `Parser` object: `const Parser = require('table-parser'); const parsedData = Parser.parse(data);`Use the CommonJS `require()` function: `const Parser = require('table-parser');` If you are in an ES Module context and absolutely need to load it, use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Parser = require('table-parser');`No dependency data recorded yet.