Socket
Socket
Sign inDemoInstall

lynx

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lynx - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

64

lib/lynx.js

@@ -29,3 +29,3 @@ var dgram = require('dgram')

// #### @options.socket {Object} Optional socket if we want to share
// #### @options.onError {Function} A function to execute on errors
// #### @options.on_error {Function} A function to execute on errors
//

@@ -61,4 +61,4 @@ // var client = new lynx('localhost', 8125);

//
this.onError = options && typeof options.onError === "function"
? options.onError
this.on_error = options && typeof options.on_error === 'function'
? options.on_error
: this._default_error_handler

@@ -75,9 +75,9 @@ ;

this.parser.on('error', this.onError);
this.parser.on('stat', function (text, statObj) {
this.parser.on('error', this.on_error);
this.parser.on('stat', function (text, stat_obj) {
var stat = {};
stat[statObj.stat] = statObj.value + '|' + statObj.type;
if(statObj.sample_rate) {
stat[statObj.stat] += '@' + statObj.sample_rate;
self.send(stat, parseFloat(statObj.sample_rate));
stat[stat_obj.stat] = stat_obj.value + '|' + stat_obj.type;
if(stat_obj.sample_rate) {
stat[stat_obj.stat] += '@' + stat_obj.sample_rate;
self.send(stat, parseFloat(stat_obj.sample_rate));
}

@@ -99,3 +99,3 @@ else {

// var client = new lynx('localhost', 8125);
// var timer = client.Timer("foo");
// var timer = client.Timer('foo');
//

@@ -204,6 +204,6 @@ // //

//
this.onError(
{ "message" : "Can't set if its not even an array by now"
, "f" : "count"
, "args" : arguments
this.on_error(
{ message : "Can't set if its not even an array by now"
, f : 'count'
, args : arguments
});

@@ -220,6 +220,6 @@ return;

//
this.onError(
{ "message" : "Must be either a number or a string"
, "f" : "count"
, "args" : arguments
this.on_error(
{ message : 'Must be either a number or a string'
, f : 'count'
, args : arguments
});

@@ -234,3 +234,3 @@ return;

for(var i in stats) {
batch[stats[i]] = delta + "|c";
batch[stats[i]] = delta + '|c';
}

@@ -258,3 +258,3 @@

var stats = {};
stats[stat] = duration + "|ms";
stats[stat] = duration + '|ms';
this.send(stats, sample_rate);

@@ -277,3 +277,3 @@ };

var stats = {};
stats[stat] = value + "|s";
stats[stat] = value + '|s';
this.send(stats, sample_rate);

@@ -296,3 +296,3 @@ };

var stats = {};
stats[stat] = value + "|g";
stats[stat] = value + '|g';
this.send(stats, sample_rate);

@@ -336,6 +336,6 @@ };

//
this.onError(
{ "message" : "Nothing to send"
, "f" : "send"
, "args" : arguments
this.on_error(
{ message : 'Nothing to send'
, f : 'send'
, args : arguments
});

@@ -351,4 +351,4 @@ return;

send_data = all_stats.map(function construct_stat(stat) {
return stat + ":" + sampled_stats[stat];
}).join("\n");
return stat + ':' + sampled_stats[stat];
}).join('\n');

@@ -379,6 +379,6 @@ //

err.reason = err.message;
err.f = "send";
err.message = "Failed sending the buffer";
err.f = 'send';
err.message = 'Failed sending the buffer';
err.args = arguments;
self.onError(err);
self.on_error(err);
return;

@@ -534,3 +534,3 @@ });

value = stats[stat];
sampled_stats[stat] = value + "|@" + sample_rate;
sampled_stats[stat] = value + '|@' + sample_rate;
});

@@ -537,0 +537,0 @@ }

{ "name" : "lynx"
, "description" : "Minimalistic StatsD client for Node.js programs"
, "version" : "0.0.5"
, "version" : "0.0.6"
, "author" : "Lloyd Hilaiel"

@@ -5,0 +5,0 @@ , "contributors": [ "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)" ]

@@ -9,2 +9,3 @@ # lynx

statsd
* **Streams** — You can stream in and out of a `lynx` connection
* **Re-usable UDP Connections** — Keeps UDP connections open for a certain time

@@ -47,5 +48,5 @@ * **Errors** — Pluggable error handling, by default errors are ignored

``` js
createDelayedStream()
fs.createReadStream('file.statsd')
.pipe(new lynx('localhost', port))
.pipe(createTestStream(t))
.pipe(fs.createReadStream('file-fixed.statsd'))
;

@@ -98,3 +99,2 @@ ```

, "boaz": "40|s" // set
, ""
}, 0.1); // sample rate at `0.1`

@@ -109,10 +109,10 @@ ```

By default `errors` get logged. If you wish to change this behavior simply specify a `onError` function when instantiating the `lynx` client.
By default `errors` get logged. If you wish to change this behavior simply specify a `on_error` function when instantiating the `lynx` client.
``` js
function onError(err) {
function on_error(err) {
console.log(err.message);
}
var connection = new lynx('localhost', 1234, {onError: onError});
var connection = new lynx('localhost', 1234, {on_error: on_error});
```

@@ -119,0 +119,0 @@

@@ -5,7 +5,7 @@ var macros = require('./macros')

, test = macros.test
, fixture = require("./fixtures/errors.json")
, fixture = require('./fixtures/errors.json')
;
test('errors', function (t) {
function onError(actual) {
function on_error(actual) {
var expected = fixture.shift();

@@ -16,4 +16,4 @@ //

//
t.ok(actual.f, "should have a reference to the function");
t.ok(actual.args, "args should be supplied");
t.ok(actual.f, 'should have a reference to the function');
t.ok(actual.args, 'args should be supplied');

@@ -39,3 +39,3 @@ //

//
var connection = new lynx('locahost', port, {onError: onError});
var connection = new lynx('locahost', port, {on_error: on_error});

@@ -42,0 +42,0 @@ connection.count(1);

@@ -43,3 +43,3 @@ var macros = require('./macros')

//
test("sampling", function (t) {
test('sampling', function (t) {
var server = udpServer(function (message, remote) {

@@ -53,4 +53,4 @@ count++;

finished = true;
t.ok(true, "Reached " + DESIRED + " on " + (TOTAL - coll.length) +
" packets.");
t.ok(true, 'Reached ' + DESIRED + ' on ' + (TOTAL - coll.length) +
' packets.');
server.close();

@@ -73,3 +73,3 @@ }

//
connection.gauge("spl.foo", 500, SAMPLE);
connection.gauge('spl.foo', 500, SAMPLE);
process.nextTick(iterate);

@@ -82,3 +82,3 @@ }, Math.ceil(Math.random() * 10));

if (finished) {
t.ok(true, "Reached " + DESIRED + " on " + TOTAL + " packets.");
t.ok(true, 'Reached ' + DESIRED + ' on ' + TOTAL + ' packets.');
t.end();

@@ -91,4 +91,4 @@ return;

//
t.ok(false, "Didnt reach the desired amount of packets " + DESIRED +
"/" + TOTAL + " was -> " + count);
t.ok(false, 'Didnt reach the desired amount of packets ' + DESIRED +
'/' + TOTAL + ' was -> ' + count);
server.close();

@@ -95,0 +95,0 @@ t.end();

@@ -7,4 +7,4 @@ var Stream = require('stream')

, test = macros.test
, fixture_send = require("./fixtures/stream-send.json")
, fixture_recv = require("./fixtures/stream-recv.json")
, fixture_send = require('./fixtures/stream-send.json')
, fixture_recv = require('./fixtures/stream-recv.json')
;

@@ -68,3 +68,3 @@

var expected = fixture_recv.shift();
t.equal(expected, buf.toString(), "===" + expected);
t.equal(expected, buf.toString(), ' should be equal to ' + expected);
if(fixture_recv.length === 0) {

@@ -110,3 +110,3 @@ test_stream.end();

//
// ### function onError(err)
// ### function on_error(err)
// #### @err {Error} Error object

@@ -116,3 +116,3 @@ //

//
function onError(err) {
function on_error(err) {
t.equal({}, err, "didn't expect any errors");

@@ -128,3 +128,3 @@ //

//
var conn = new lynx('localhost', port, {onError: onError});
var conn = new lynx('localhost', port, {on_error: on_error});

@@ -131,0 +131,0 @@ createDelayedStream()

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