From 5c5e54e4859b72eb627b506bcd1ed10d2038622f Mon Sep 17 00:00:00 2001 From: Serphentas Date: Fri, 5 Jan 2018 23:52:54 +0100 Subject: [PATCH] fix #6 --- lib/GraphiteClient.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/GraphiteClient.js b/lib/GraphiteClient.js index 8ec201c..39c4ad8 100644 --- a/lib/GraphiteClient.js +++ b/lib/GraphiteClient.js @@ -30,12 +30,13 @@ GraphiteClient.flatten = function(obj, flat, prefix) { GraphiteClient.prototype.write = function(metrics, timestamp, cb) { if (typeof timestamp === 'function') { - cb = timestamp; - timestamp = null; + cb = timestamp; + timestamp = undefined; } - timestamp = timestamp || Date.now(); - timestamp = Math.floor(timestamp / 1000); + if (timestamp === undefined) { + timestamp = Math.floor(Date.now() / 1000); + } this._carbon.write(GraphiteClient.flatten(metrics), timestamp, cb); };