connection-parse is a lightweight utility designed to parse TCP connection strings, transforming formats like `1.1.1.1:1111` into structured objects containing `host`, `port`, and the original `string`. It also supports parsing multiple connection strings from arrays, arguments, or weighted object formats, and allows for custom merge functions to extend the parsed data. Originally extracted from common logic in other modules, its primary purpose is simplifying the handling of server addresses. The package is currently at version 0.0.7, with its last publish occurring over nine years ago, indicating it is an abandoned project with no active development or maintenance. Users should be aware of its unmaintained status and consider modern alternatives for new projects, as it lacks contemporary features like ESM support and TypeScript typings.
npm install connection-parseVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic TCP connection string parsing for single, multiple, and weighted servers, including extending output with a custom `merge` function.
Use `const parse = require('connection-parse');` instead of `import parse from 'connection-parse';` in your code.For new projects, consider using a more modern and actively maintained parsing library or implement the simple parsing logic yourself. For existing projects, audit its usage carefully.
You will need to create a declaration file (e.g., `connection-parse.d.ts`) or use a tool like `@types/connection-parse` if one exists (unlikely given its age), or suppress type errors with `@ts-ignore` (not recommended).
Be mindful of where and how `parse.merge` is called. If different parsing behaviors are needed, ensure the merge function is reset or reconfigured appropriately, or avoid using `parse.merge` if global state mutation is problematic.
Ensure you are using the correct CommonJS import for the default export: `const parse = require('connection-parse');`This package is CommonJS-only. If your project is ESM, you must use a dynamic import workaround (`import('connection-parse')`) or convert your file to CommonJS. However, given the package's abandoned status, migrating to a modern alternative is recommended.Create a custom type declaration for `connection-parse` or cast the result of `parse` to an `any` type (less recommended) to inform TypeScript about the added properties.
No dependency data recorded yet.