Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connection-parse

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connection-parse

Simple TCP connection string parser

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
137K
increased by3.35%
Maintainers
1
Weekly downloads
 
Created
Source

connection-parse

Simple TCP connection string parser, and nothing more then that. It simply transforms 1.1.1.1:1111 in to a simple parsed object. I seem to do this a lot in most of my modules such as hashring, memcached and failover. So it makes sense to extract this in to a small util.

Installation

Install this module using npm:

npm install connection-parse --save

The --save automatically adds the package and version to your package.json.

API

var parse = require('connection-parse');

parse('1.1.1.1:1111')
parse('1.1.1.1:1111', '1.3.3.4:1345');
parse(['1.1.1.1:1111', '1.3.3.4:1345']);
parse({ '1.1.1.1:1111': 100 });

{
  servers: [{
    string: '1.1.1.1:1111',
    host: '1.1.1.1',
    port: 1111
  }],
  regular: ['1.1.1.1:1111'],
  weighted: {
    '1.1.1.1:1111': 100 // or 1 by default
  }
}

// It also accepts custom parsers
parse.merge(function (data) {
  data.foo = 'bar';
  return data;
});

Then the server instances will also have an extra property, `foo`.

License

MIT

Keywords

FAQs

Package last updated on 22 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc