Registry / serialization / table-parser

table-parser

JSON →
library1.0.1jsnpmunverified

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-parser
INSTALL
IMPORT
SIG · TABLE-PARSER
T
table-parser
serializationjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
const Parser = require('table-parser');
import Parser from 'table-parser';
This package is CommonJS-only (published in 2018) and does not natively support ES Modules. Attempting to use `import` directly will result in a runtime error.
Parser.parse
const Parser = require('table-parser'); const parsedData = Parser.parse(data);
import { parse } from 'table-parser';
The `parse` function is a method of the default exported `Parser` object, not a named export. It must be accessed as a property of the `Parser` object.

Demonstrates parsing a multi-line string resembling `ps` command output into an array of JavaScript objects.

const FS = require('fs'); const Parser = require('table-parser'); // Simulate a shell output file const mockLogContent = ` PID TTY TIME CMD 49692 ttys000 0:00.06 login -pfl neekey /bin/bash -c exec -la bash /bin/bash 49693 ttys000 0:00.06 -bash 54195 ttys000 0:00.09 node run 56266 ttys005 0:00.06 login -pfl neekey /bin/bash -c exec -la bash /bin/bash 56269 ttys005 0:00.04 -bash 56463 ttys005 0:00.09 node test.js 56464 ttys005 0:00.01 ps -a`; // In a real scenario, you would read from a file: // const data = FS.readFileSync('./ps.log').toString(); const parsedData = Parser.parse(mockLogContent); console.log(parsedData);
Debug
Known issues
gotchaThe `table-parser` package has not been updated since April 2018, indicating it is likely abandoned. This means it may have compatibility issues with newer Node.js versions, unresolved bugs, or potential security vulnerabilities.
fix
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.
affects: >=1.0.0
gotchaThis package is CommonJS-only. It does not natively support ES Modules (`import`/`export` syntax). Attempting to import it directly in an ESM project will cause a runtime error.
fix
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');`
affects: >=1.0.0
gotchaThe parser has specific and potentially counter-intuitive handling for double-quoted strings. If a string starts with a double quote, that initial quote is removed. However, double quotes occurring elsewhere within the string are preserved, and all values are treated as arrays of strings by default.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Parser.parse is not a function
The `parse` method is being called on an undefined or incorrect object, often due to a mistaken import pattern or failed `require`.
fix
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);`
SyntaxError: Cannot use import statement outside a module
Attempting to use ES Module `import` syntax to load a CommonJS-only package in an environment that is not configured for Node.js's ESM compatibility.
fix
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');`
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
table-parser — npm install table-parser · libregistry