Skip to content

Commit

Permalink
Merge pull request #11 from HughePaul/bugfix/issue-10
Browse files Browse the repository at this point in the history
Set default timestamp when both time and callback are omitted
  • Loading branch information
Serphentas authored Mar 9, 2018
2 parents bf8bfc5 + 07aee8b commit 4b32088
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ language: node_js
node_js:
- 0.4
- 0.6
- 4
- 8
5 changes: 4 additions & 1 deletion lib/GraphiteClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ GraphiteClient.appendTags = function(flatMetrics, tags) {
GraphiteClient.prototype.write = function(metrics, timestamp, cb) {
if (typeof timestamp === 'function') {
cb = timestamp;
timestamp = Date.now();
timestamp = null;
}

// default timestamp to now
timestamp = timestamp || Date.now();

// cutting timestamp for precision up to the second
timestamp = Math.floor(timestamp / 1000);

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
},
"main": "./index",
"scripts": {
"test": "make test"
"test": "npm run test:unit && npm run test:integration",
"test:unit": "make test type=unit",
"test:integration": "make test type=integration"
},
"engines": {
"node": "*"
Expand Down

0 comments on commit 4b32088

Please sign in to comment.