Registry / serialization / parse-listing

parse-listing

JSON →
library1.1.3jsnpmunverified

Small library to parse file listings (e.g., ls, dir) into JavaScript objects. Currently at v1.1.3, last released in 2018 with a fix for MS-DOS folder names containing numbers. It supports Unix and DOS/Windows formats automatically. The library is stable but in maintenance mode; no new features are expected. Compared to alternatives, it is minimal and has no dependencies.

npm install parse-listing
INSTALL
IMPORT
SIG · PARSE-LISTING
P
parse-listing
serializationjavascriptv1.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Parser
✓ const Parser = require('parse-listing');
✗ import Parser from 'parse-listing'; // Not ESM, use require
This package is CommonJS only; no ESM support.
parseEntries
✓ Parser.parseEntries(str, callback);
✗ Parser.parseEntries(str).then(callback); // Not promise-based
parseEntries is async but uses callback, not Promises.
parseEntry
✓ const entry = Parser.parseEntry(str);
✗ Parser.parseEntry(str, callback); // parseEntry is synchronous
parseEntry is synchronous and returns an object directly.

Parses a Unix 'ls -la' formatted string into objects, logging name, type, and size for each entry.

const Parser = require('parse-listing'); const unixListing = `drwxr-xr-x 5 1001 1001 4096 Jan 09 11:52 . drwxr-xr-x 4 0 0 4096 Sep 19 13:50 .. -rw------- 1 1001 1001 1118 Jan 09 12:09 .bash_history -rw------- 1 1001 1001 943 Jan 09 11:52 .viminfo drwxrwxr-x 5 1001 1001 4096 Jan 09 11:52 inaccessible drwxrwxrwx 2 1001 1001 4096 Sep 21 11:20 project1 drwx------ 2 1001 1001 4096 Oct 19 16:17 project2`; Parser.parseEntries(unixListing, function(err, entries) { if (err) { console.error(err); return; } entries.forEach(function(entry) { console.log('Name:', entry.name, 'Type:', entry.type, 'Size:', entry.size); }); });
Debug
Known issues
breakingCallback error handling: if you pass invalid input (e.g., null or non-string), the library may throw synchronously or call callback with error depending on the method.
fix
Always wrap in try-catch for parseEntry or check input validity before calling parseEntries.
affects: >=1.0.0
gotchaTime parsing: The 'time' field is a timestamp in milliseconds, but some entries may not parse correctly (e.g., non-standard date formats).
fix
Use a library like moment.js to parse the raw date string if needed; check entry.time for NaN.
affects: >=1.0.0
deprecatedNo updates since 2018: The package is in maintenance-only mode. Security or compatibility issues may not be addressed.
fix
Consider switching to 'ftp-parse-listing' or writing a custom parser if you need active maintenance.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'parse-listing'
Package not installed or module path incorrect.
fix
Run 'npm install parse-listing' and ensure require('parse-listing') is correct.
TypeError: Parser.parseEntries is not a function
Using import instead of require (ESM vs CJS).
fix
Use const Parser = require('parse-listing'); instead of import.
undefined is not a function (callback)
Passing undefined as callback to parseEntries.
fix
Ensure callback is a function: Parser.parseEntries(str, function(err, entries) { ... });
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
noderequiredRuns on Node.js >=0.6.21
Agent activity
6 hits · last 30 days
node
6
Resources
parse-listing — npm install parse-listing · libregistry