{"id":14587,"library":"ftp-response-parser","title":"FTP Response Stream Parser","description":"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.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/sergi/ftp-response-parser","tags":["javascript","ftp","response","protocol","files","server","client","async"],"install":[{"cmd":"npm install ftp-response-parser","lang":"bash","label":"npm"},{"cmd":"yarn add ftp-response-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add ftp-response-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import { ResponseParser } from 'ftp-response-parser';","symbol":"ResponseParser","correct":"const ResponseParser = require('ftp-response-parser');"}],"quickstart":{"code":"const ResponseParser = require('ftp-response-parser');\nconst myParser = new ResponseParser();\n\nmyParser.on('readable', function() {\n  let line;\n  while ((line = myParser.read()) !== null) {\n    console.log(`Code: ${line.code}, Text: ${line.text}`);\n  }\n});\n\nmyParser.on('error', (err) => {\n  console.error('Parser encountered an error:', err);\n});\n\nmyParser.on('end', () => {\n  console.log('End of FTP response stream.');\n});\n\n// Example FTP multi-line response string\nconst 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`;\n\nmyParser.write(ftpResponse);\nmyParser.end(); // Signal that no more data will be written\n\nconsole.log('Parser initialized and example data sent.');","lang":"javascript","description":"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."},"warnings":[{"fix":"Use CommonJS `require()` syntax: `const ResponseParser = require('ftp-response-parser');` for module loading.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"The `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).","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"As 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change your import statement to `const ResponseParser = require('ftp-response-parser');`.","cause":"Attempting to use an ESM `import` statement for a CommonJS-only module, which does not correctly resolve the constructor.","error":"TypeError: ftp-response-parser is not a constructor"},{"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.","cause":"Invoking `parser.write()` on the stream after `parser.end()` has already been called, which signifies no more data will be written.","error":"Error: read after end"},{"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.","cause":"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.","error":"Incomplete parsing of final FTP response lines (no specific error message)"}],"ecosystem":"npm"}