Registry / http-networking / ftp-response-parser

ftp-response-parser

JSON →
library1.0.1jsnpmunverified

The `ftp-response-parser` package provides a lightweight, streaming parser specifically designed for handling FTP server response format strings. It efficiently processes incoming FTP protocol messages, including multi-line responses, and emits structured JavaScript objects. Each emitted object includes the numeric status `code`, the full `text` of the response, and boolean flags `isMark` and `isError`. This library is currently at version 1.0.1, with its last update occurring over a decade ago. It functions as a classic Node.js `Stream` and is primarily differentiated by its low-overhead, event-driven approach to parsing continuous streams of FTP data, making it suitable for integration into custom FTP client implementations that require incremental response processing.

npm install ftp-response-parser
INSTALL
IMPORT
SIG · FTP-RESPONSE-PARSE
F
ftp-response-parser
http-networkingjavascriptv1.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.

ResponseParser
const ResponseParser = require('ftp-response-parser');
import { ResponseParser } from 'ftp-response-parser';
This package is CommonJS-only, exporting the `ResponseParser` class directly as the module's default export. Named imports or ESM default imports are not supported.

Demonstrates how to instantiate the `ResponseParser`, listen for `readable` events to process parsed FTP response objects, handle potential errors, and feed it a multi-line FTP response string, ensuring the stream is properly terminated.

const ResponseParser = require('ftp-response-parser'); const myParser = new ResponseParser(); myParser.on('readable', function() { let line; while ((line = myParser.read()) !== null) { console.log(`Code: ${line.code}, Text: ${line.text}`); } }); myParser.on('error', (err) => { console.error('Parser encountered an error:', err); }); myParser.on('end', () => { console.log('End of FTP response stream.'); }); // Example FTP multi-line response string const ftpResponse = `211-Features supported:\n EPRT\n EPSV\n MDTM\n MLST type*;perm*;size*;modify*;unique*;unix.mode;unix.uid;unix.gid;\n REST STREAM\n SIZE\n TVFS\n UTF8\n211 End FEAT.\n215 UNIX Type: L8\n331 Username ok, send password.\n230 Login successful.\n200 Type set to: Binary.\n250 "/test" is the current directory.\n`; myParser.write(ftpResponse); myParser.end(); // Signal that no more data will be written console.log('Parser initialized and example data sent.');
Debug
Known issues
breakingThis package is CommonJS-only and does not provide an ESM export. Direct `import` statements (e.g., `import { ResponseParser } from 'ftp-response-parser';`) will result in a runtime error.
fix
Use CommonJS `require()` syntax: `const ResponseParser = require('ftp-response-parser');` for module loading.
affects: >=1.0.0
gotchaThe `ftp-response-parser` package is abandoned, with its last update occurring over a decade ago (May 2013). It may contain unaddressed bugs, security vulnerabilities, or compatibility issues with modern Node.js versions (e.g., Node.js v16+ and later).
fix
Evaluate alternatives if long-term support, security, or guaranteed compatibility with the latest Node.js runtime is required. Consider migrating to a more actively developed FTP client library or forking and maintaining this package if its core functionality is essential.
affects: >=1.0.0
gotchaAs a Node.js `Stream`, if the input stream is not explicitly ended (via `parser.end()`) after all data has been written, the parser might hold onto buffered data indefinitely, potentially leading to memory leaks or incomplete parsing of the final response segments.
fix
Always call `parser.end()` when the entire input data has been fed to the parser to ensure all buffered data is processed and the stream is properly terminated, allowing the `end` event to fire.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ftp-response-parser is not a constructor
Attempting to use an ESM `import` statement for a CommonJS-only module, which does not correctly resolve the constructor.
fix
Change your import statement to `const ResponseParser = require('ftp-response-parser');`.
Error: read after end
Invoking `parser.write()` on the stream after `parser.end()` has already been called, which signifies no more data will be written.
fix
Ensure all data is written to the parser using `parser.write()` before `parser.end()` is invoked. `parser.end()` should be the last write operation.
Incomplete parsing of final FTP response lines (no specific error message)
The readable stream's `read()` method is not being called sufficiently often in response to the `'readable'` event, or `parser.end()` was not called after all input data was provided.
fix
Ensure your `on('readable')` listener contains a `while` loop that continuously calls `parser.read()` until it returns `null`. Additionally, confirm `parser.end()` is called once all expected input has been written.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
ftp-response-parser — npm install ftp-response-parser · libregistry