Comparing version 0.0.6 to 0.0.7
@@ -110,2 +110,3 @@ var dgram = require('dgram') | ||
, start_time = new Date ().getTime() | ||
, stopped = false | ||
; | ||
@@ -120,4 +121,27 @@ | ||
function stop() { | ||
// | ||
// If timer is already stopped just ignore the request | ||
// | ||
if(stopped) { | ||
self.on_error( | ||
{ message : "Can't stop a timer twice" | ||
, f : 'stop' | ||
}); | ||
return; | ||
} | ||
// | ||
// Calculate duration | ||
// | ||
var duration = new Date ().getTime() - start_time; | ||
// | ||
// Emit | ||
// | ||
self.timing(stat, duration, sample_rate); | ||
// | ||
// So no one stops a timer twice (causing two emits) | ||
// | ||
stopped = true; | ||
} | ||
@@ -124,0 +148,0 @@ |
{ "name" : "lynx" | ||
, "description" : "Minimalistic StatsD client for Node.js programs" | ||
, "version" : "0.0.6" | ||
, "version" : "0.0.7" | ||
, "author" : "Lloyd Hilaiel" | ||
@@ -5,0 +5,0 @@ , "contributors": [ "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)" ] |
@@ -27,2 +27,12 @@ var macros = require('./macros'); | ||
timer.stop(); | ||
// | ||
// Atempt to stop already stopped timer | ||
// Will console.log `Can't stop a timer twice` | ||
// | ||
// We are not testing for this, cause its just an error message | ||
// but this would be raised on scenarios where a more strict error handler | ||
// is enforced by the user | ||
// | ||
second_timer.stop(); | ||
}, 200); | ||
@@ -29,0 +39,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38477
1153