connection-parse / 0.0.7 last updated a year ago created on Feb 9th 2013

Install

npm install --save connection-parse

Clone

git clone git@github.com:3rd-Eden/connection-parse.git

dependencies

No dependencies listed.

maintainers

v1 v1
3rdeden

versions 8 total

0.0.7 3 years ago V1
0.0.6 3 years ago V1
0.0.5 3 years ago V1
0.0.4 3 years ago V1
0.0.3 3 years ago V1
0.0.2 3 years ago V1
0.0.1 3 years ago V1
0.0.0 3 years ago V1
9388 Downloads yesterday.

readme

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

Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.