From e72f71f4e2f369bae879be8a5b7cd098d6d77186 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:07:21 -0400 Subject: [PATCH 01/51] update stopwatch version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09e096d..4203d1d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": { "statman-gauge": "^1.0.5", "statman-meter": "^1.0.2", - "statman-stopwatch": "^2.4.0", + "statman-stopwatch": "^2.7.0", "underscore": "^1.8.3" }, "devDependencies": { From acce07e5aa38995179bfce38d696cf0b71f76e59 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:07:33 -0400 Subject: [PATCH 02/51] removed unused variable --- lib/statman.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/statman.js b/lib/statman.js index 03eee2e..041e265 100644 --- a/lib/statman.js +++ b/lib/statman.js @@ -2,8 +2,6 @@ var Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); var Meter = module.exports.Meter = require('statman-meter'); var Gauge = module.exports.Gauge = require('statman-gauge'); -var _ = require('underscore'); - var _registry = require('./registry'); // var httpFilters = require('./httpFilters'); From 6084c468b9fffb1503af63e58872e49bce2f4052 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:08:11 -0400 Subject: [PATCH 03/51] cleanup var/const --- lib/statman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statman.js b/lib/statman.js index 041e265..2a8c890 100644 --- a/lib/statman.js +++ b/lib/statman.js @@ -1,4 +1,4 @@ -var Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); +const Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); var Meter = module.exports.Meter = require('statman-meter'); var Gauge = module.exports.Gauge = require('statman-gauge'); From 4d755871c5b57f90ac75b47e1404d0446c308a4b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:08:18 -0400 Subject: [PATCH 04/51] cleanup var/const --- lib/statman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statman.js b/lib/statman.js index 2a8c890..31307af 100644 --- a/lib/statman.js +++ b/lib/statman.js @@ -1,5 +1,5 @@ const Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); -var Meter = module.exports.Meter = require('statman-meter'); +const Meter = module.exports.Meter = require('statman-meter'); var Gauge = module.exports.Gauge = require('statman-gauge'); var _registry = require('./registry'); From f81d5a2e3bb011c1c00f0c7ec30d8ba9723cbe7b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:08:23 -0400 Subject: [PATCH 05/51] cleanup var/const --- lib/statman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statman.js b/lib/statman.js index 31307af..ac9eb39 100644 --- a/lib/statman.js +++ b/lib/statman.js @@ -1,6 +1,6 @@ const Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); const Meter = module.exports.Meter = require('statman-meter'); -var Gauge = module.exports.Gauge = require('statman-gauge'); +const Gauge = module.exports.Gauge = require('statman-gauge'); var _registry = require('./registry'); From 19da8cb8d5b32c37ec1b70a035fa458929e61a5d Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:08:29 -0400 Subject: [PATCH 06/51] cleanup var/const --- lib/statman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statman.js b/lib/statman.js index ac9eb39..1d3cb42 100644 --- a/lib/statman.js +++ b/lib/statman.js @@ -2,7 +2,7 @@ const Stopwatch = module.exports.Stopwatch = require('statman-stopwatch'); const Meter = module.exports.Meter = require('statman-meter'); const Gauge = module.exports.Gauge = require('statman-gauge'); -var _registry = require('./registry'); +const _registry = require('./registry'); // var httpFilters = require('./httpFilters'); // exports.httpFilters = httpFilters; From 69fc90f127114ac27b1c586c653fe4ecd335da87 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:12:05 -0400 Subject: [PATCH 07/51] move isEmpty to lodash --- lib/registry.js | 9 +++++---- package.json | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/registry.js b/lib/registry.js index e658d43..e5f72cb 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -1,4 +1,5 @@ var _ = require('underscore'); +const isEmpty = require('lodash.isempty'); //global collection of metrics. Having this global makes it easy for other parts of application to access var _metrics; @@ -9,13 +10,13 @@ function reset() { } function register(key, metric) { - if (_.isEmpty(metric)) { + if (isEmpty(metric)) { metric = key; key = null; } key = determineKey(key, metric); - if (_.isEmpty(key)) { + if (isEmpty(key)) { throw Error('Cannot register a metric without a key. Key can be specified as a parameter, or supplied in the metric as name, name(), or getName()'); } @@ -24,7 +25,7 @@ function register(key, metric) { function determineKey(key, metric) { - if (_.isEmpty(key)) { + if (isEmpty(key)) { if (_.isFunction(metric.name)) { key = metric.name(); } @@ -45,7 +46,7 @@ function findOrCreate(metricname, constructor) { existingMetric = get(metricname); } - if (_.isEmpty(existingMetric)) { + if (isEmpty(existingMetric)) { var newMetric = new constructor(metricname); return register(newMetric); } else { diff --git a/package.json b/package.json index 4203d1d..7315dfb 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "url": "https://github.com/jasonray/statman/issues" }, "dependencies": { + "lodash.isempty": "^4.4.0", "statman-gauge": "^1.0.5", "statman-meter": "^1.0.2", "statman-stopwatch": "^2.7.0", From 95ae01fe8b462841072c6cfbac31616349d0bc8b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:13:30 -0400 Subject: [PATCH 08/51] move isFunction from underscore to lodash --- lib/registry.js | 6 ++++-- package.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/registry.js b/lib/registry.js index e5f72cb..902d403 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -1,5 +1,7 @@ var _ = require('underscore'); const isEmpty = require('lodash.isempty'); +const isFunction = require('lodash.isfunction'); + //global collection of metrics. Having this global makes it easy for other parts of application to access var _metrics; @@ -26,10 +28,10 @@ function register(key, metric) { function determineKey(key, metric) { if (isEmpty(key)) { - if (_.isFunction(metric.name)) { + if (isFunction(metric.name)) { key = metric.name(); } - else if (_.isFunction(metric.getName)) { + else if (isFunction(metric.getName)) { key = metric.getName(); } else if (metric.name) { diff --git a/package.json b/package.json index 7315dfb..4495028 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "lodash.isempty": "^4.4.0", + "lodash.isfunction": "^3.0.9", "statman-gauge": "^1.0.5", "statman-meter": "^1.0.2", "statman-stopwatch": "^2.7.0", From 7e25a48782078df863fe88428378728683123bdb Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:13:48 -0400 Subject: [PATCH 09/51] drop underscore variable --- lib/registry.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/registry.js b/lib/registry.js index 902d403..0a27962 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -1,4 +1,3 @@ -var _ = require('underscore'); const isEmpty = require('lodash.isempty'); const isFunction = require('lodash.isfunction'); From 6c9fe21dcaf1eb6651496280a5ebbd840103e49c Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:15:13 -0400 Subject: [PATCH 10/51] move isNull from underscore to lodash --- package.json | 1 + test/testhelper.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4495028..c877c4d 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "dependencies": { "lodash.isempty": "^4.4.0", "lodash.isfunction": "^3.0.9", + "lodash.isnull": "^3.0.0", "statman-gauge": "^1.0.5", "statman-meter": "^1.0.2", "statman-stopwatch": "^2.7.0", diff --git a/test/testhelper.js b/test/testhelper.js index fce61c4..8c13c58 100644 --- a/test/testhelper.js +++ b/test/testhelper.js @@ -1,9 +1,9 @@ -var _ = require('underscore'); var assert = require('assert'); +const isNull = require('lodash.isnull'); function assertCloseEnough(actual, expected, acceptedVariance) { - if (_.isNull(acceptedVariance)) acceptedVariance = 10; + if (isNull(acceptedVariance)) acceptedVariance = 10; var lowerThreshold = expected - acceptedVariance; var upperThreshold = expected + acceptedVariance; var message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; From 9f9b9fc300f88f7915abbf69865331d997b3b619 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:15:29 -0400 Subject: [PATCH 11/51] cleanup --- test/testhelper.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/testhelper.js b/test/testhelper.js index 8c13c58..d5df668 100644 --- a/test/testhelper.js +++ b/test/testhelper.js @@ -1,7 +1,6 @@ -var assert = require('assert'); +const assert = require('assert'); const isNull = require('lodash.isnull'); - function assertCloseEnough(actual, expected, acceptedVariance) { if (isNull(acceptedVariance)) acceptedVariance = 10; var lowerThreshold = expected - acceptedVariance; From 3a511892dddb4c2a45ad4401005e0ac2efd6c72b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:15:56 -0400 Subject: [PATCH 12/51] drop unused variable --- test/stopwatch-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 5618c36..d71fdbf 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -6,7 +6,6 @@ var assert = require('assert'); var should = require('should'); var statman = require('../lib/statman'); var TestHelper = require('./testhelper'); -var _ = require('underscore'); describe('stopwatch (smoke test)', function () { beforeEach(function() { From 5e6c6c20e4e7a8f76b0674d7270456f8567a975f Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:16:16 -0400 Subject: [PATCH 13/51] var/const cleanup --- test/stopwatch-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index d71fdbf..d993703 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -1,7 +1,7 @@ /*jslint node: true */ "use strict"; -var mocha = require('mocha'); +const mocha = require('mocha'); var assert = require('assert'); var should = require('should'); var statman = require('../lib/statman'); From 794873371744cde75afa455ec9cc25bdc796947f Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:16:24 -0400 Subject: [PATCH 14/51] var/const cleanup --- test/stopwatch-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index d993703..4212cc3 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -2,7 +2,7 @@ "use strict"; const mocha = require('mocha'); -var assert = require('assert'); +const assert = require('assert'); var should = require('should'); var statman = require('../lib/statman'); var TestHelper = require('./testhelper'); From dc7bc5ade6490743875222b928eeaf52ea76067b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:16:31 -0400 Subject: [PATCH 15/51] var/const cleanup --- test/stopwatch-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 4212cc3..fb84cc9 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -3,7 +3,7 @@ const mocha = require('mocha'); const assert = require('assert'); -var should = require('should'); +const should = require('should'); var statman = require('../lib/statman'); var TestHelper = require('./testhelper'); From d0fdbf0f6bc96ed52fe8a4af9ddf8ad0db2d5de4 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:16:37 -0400 Subject: [PATCH 16/51] var/const cleanup --- test/stopwatch-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index fb84cc9..2811d25 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -4,7 +4,7 @@ const mocha = require('mocha'); const assert = require('assert'); const should = require('should'); -var statman = require('../lib/statman'); +const statman = require('../lib/statman'); var TestHelper = require('./testhelper'); describe('stopwatch (smoke test)', function () { From 86b979e9fba89d8eb20c56e37761b56f098a0114 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:16:43 -0400 Subject: [PATCH 17/51] var/const cleanup --- test/stopwatch-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 2811d25..5389d11 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -5,7 +5,7 @@ const mocha = require('mocha'); const assert = require('assert'); const should = require('should'); const statman = require('../lib/statman'); -var TestHelper = require('./testhelper'); +const TestHelper = require('./testhelper'); describe('stopwatch (smoke test)', function () { beforeEach(function() { From f4dadb18a2c9d2ffd9be1734f804e3e5e1d4fbc6 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:19:14 -0400 Subject: [PATCH 18/51] use testhelper --- test/stopwatch-test.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 5389d11..73f50bb 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -6,6 +6,7 @@ const assert = require('assert'); const should = require('should'); const statman = require('../lib/statman'); const TestHelper = require('./testhelper'); +const verifyDelta = TestHelper.assertCloseEnough; describe('stopwatch (smoke test)', function () { beforeEach(function() { @@ -105,9 +106,9 @@ describe('stopwatch (smoke test)', function () { //TODO: //replace with: statman.TestHelper.assertCloseEnough(testtime, delta, defaultPrecision); -function verifyDelta(expected, actual, acceptedVariance) { - var lowerThreshold = expected - acceptedVariance; - var upperThreshold = expected + acceptedVariance; - var message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; - assert.ok((actual >= lowerThreshold) && (actual <= upperThreshold), message); -} \ No newline at end of file +// function verifyDelta(expected, actual, acceptedVariance) { +// var lowerThreshold = expected - acceptedVariance; +// var upperThreshold = expected + acceptedVariance; +// var message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; +// assert.ok((actual >= lowerThreshold) && (actual <= upperThreshold), message); +// } \ No newline at end of file From 3197eb2afda0e727888ce6d20bf03d33f59d3460 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:19:34 -0400 Subject: [PATCH 19/51] cleanup --- test/stopwatch-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 73f50bb..b19f5d4 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -5,8 +5,7 @@ const mocha = require('mocha'); const assert = require('assert'); const should = require('should'); const statman = require('../lib/statman'); -const TestHelper = require('./testhelper'); -const verifyDelta = TestHelper.assertCloseEnough; +const verifyDelta = require('./testhelper').assertCloseEnough; describe('stopwatch (smoke test)', function () { beforeEach(function() { From 7312e2b93b84ac7ee16642c95ce64755d97d6b2c Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:20:02 -0400 Subject: [PATCH 20/51] cleanup --- test/stopwatch-test.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index b19f5d4..84b60f7 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -101,13 +101,4 @@ describe('stopwatch (smoke test)', function () { stopwatch.toString().should.containEql('value:'); }); }); -}); - -//TODO: -//replace with: statman.TestHelper.assertCloseEnough(testtime, delta, defaultPrecision); -// function verifyDelta(expected, actual, acceptedVariance) { -// var lowerThreshold = expected - acceptedVariance; -// var upperThreshold = expected + acceptedVariance; -// var message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; -// assert.ok((actual >= lowerThreshold) && (actual <= upperThreshold), message); -// } \ No newline at end of file +}); \ No newline at end of file From 043f709308c2e9a0a5ba2236ca92cc0e2e446063 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:21:57 -0400 Subject: [PATCH 21/51] dropped unused reference to underscore --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index c877c4d..8e66894 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "lodash.isnull": "^3.0.0", "statman-gauge": "^1.0.5", "statman-meter": "^1.0.2", - "statman-stopwatch": "^2.7.0", - "underscore": "^1.8.3" + "statman-stopwatch": "^2.7.0" }, "devDependencies": { "should": "^11.1.2", From 62f3cbff34bf5f6f3b900e0ef7ed4635e9e12510 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:22:30 -0400 Subject: [PATCH 22/51] cleanup --- lib/registry.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/registry.js b/lib/registry.js index 0a27962..f04b7ae 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -1,7 +1,6 @@ const isEmpty = require('lodash.isempty'); const isFunction = require('lodash.isfunction'); - //global collection of metrics. Having this global makes it easy for other parts of application to access var _metrics; reset(); From eff84a51b890efd0b96cedd688eb5f14c74b1e03 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:22:49 -0400 Subject: [PATCH 23/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index ece8694..ad93ec2 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -1,7 +1,7 @@ /*jslint node: true */ "use strict"; -var mocha = require('mocha'); +const mocha = require('mocha'); var assert = require('assert'); var should = require('should'); var statman = require('../lib/statman'); From 5b6ff240215d0c7fa4976cca34b438dce5eac8ed Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:22:57 -0400 Subject: [PATCH 24/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index ad93ec2..42155dc 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -2,7 +2,7 @@ "use strict"; const mocha = require('mocha'); -var assert = require('assert'); +const assert = require('assert'); var should = require('should'); var statman = require('../lib/statman'); From 0e8d4bf2aa5c95c62f37734c74e6fcee7c6f06fd Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:02 -0400 Subject: [PATCH 25/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 42155dc..3c4c44f 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -3,7 +3,7 @@ const mocha = require('mocha'); const assert = require('assert'); -var should = require('should'); +const should = require('should'); var statman = require('../lib/statman'); describe('gauge (smoke test)', function () { From 4539829858201034dde38415b3f66d6d7ec6cd2b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:07 -0400 Subject: [PATCH 26/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 3c4c44f..7c6f322 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -4,7 +4,7 @@ const mocha = require('mocha'); const assert = require('assert'); const should = require('should'); -var statman = require('../lib/statman'); +const statman = require('../lib/statman'); describe('gauge (smoke test)', function () { it('gauagename', function () { From a472ba4a203afefda9e6b8227f259c51a6f9051e Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:15 -0400 Subject: [PATCH 27/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 7c6f322..46e7f42 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -8,7 +8,7 @@ const statman = require('../lib/statman'); describe('gauge (smoke test)', function () { it('gauagename', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); assert.equal('metric-name', gauge.name()); }); From 7e19abb1c13aa7491625112849c455f0dee1b8b9 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:18 -0400 Subject: [PATCH 28/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 46e7f42..4982da4 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -13,7 +13,7 @@ describe('gauge (smoke test)', function () { }); it('increment', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.increment(); assert.equal(1, gauge.value()); }); From ff5ee846c191d7195ac4d3b0337d8b899fb434d6 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:22 -0400 Subject: [PATCH 29/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 4982da4..e2e505b 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -19,7 +19,7 @@ describe('gauge (smoke test)', function () { }); it('incrementByValue', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.set(10); gauge.increment(2); assert.equal(12, gauge.value()); From 5599d34e8487769552d36592b608b460ba99a134 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:26 -0400 Subject: [PATCH 30/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index e2e505b..963ecc7 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -26,7 +26,7 @@ describe('gauge (smoke test)', function () { }); it('decrement', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.set(10); gauge.decrement(); assert.equal(9, gauge.value()); From e623ceddfce149801ab72dd35ae3d60642f0bc44 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:29 -0400 Subject: [PATCH 31/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 963ecc7..3185a82 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -33,7 +33,7 @@ describe('gauge (smoke test)', function () { }); it('decrementByValue', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.set(10); gauge.decrement(2); assert.equal(8, gauge.value()); From f570ccf02ab8d9cbbee8f426d4a6c895ac554614 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:33 -0400 Subject: [PATCH 32/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 3185a82..87e88ae 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -40,7 +40,7 @@ describe('gauge (smoke test)', function () { }); it('set', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.set(5); assert.equal(5, gauge.value()); }); From d58d8cca3e6a3ae17f9b0827a3cd0ac7d60fed56 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:37 -0400 Subject: [PATCH 33/51] var/const cleanup --- test/gauge-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gauge-test.js b/test/gauge-test.js index 87e88ae..4a6a0bf 100644 --- a/test/gauge-test.js +++ b/test/gauge-test.js @@ -46,7 +46,7 @@ describe('gauge (smoke test)', function () { }); it('toString produces something with the value', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); gauge.set(5); gauge.toString().should.containEql(5); }); From d72bcd1420f235cf7ca82fdf687fcecfea56599d Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:23:56 -0400 Subject: [PATCH 34/51] var/const cleanup --- test/meter-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index b25bc12..a37523c 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -1,8 +1,8 @@ /*jslint node: true */ "use strict"; -var statman = require('../lib/statman'); -var should = require('should'); +const statman = require('../lib/statman'); +const should = require('should'); describe('meter (smoke test)', function () { this.timeout(5000); From 613f28e21a43673175adb701e77e8b9181dd50ed Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:24:30 -0400 Subject: [PATCH 35/51] var/const cleanup --- test/meter-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index a37523c..a5f66ca 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -8,8 +8,7 @@ describe('meter (smoke test)', function () { this.timeout(5000); it('init should return an instance of meter', function () { - var meter; - meter = new statman.Meter(); + const meter = new statman.Meter(); should.exist(meter); }); From 660f4e21853f720db52284e585e2da271399522f Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:24:40 -0400 Subject: [PATCH 36/51] var/const cleanup --- test/meter-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index a5f66ca..2766995 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -13,8 +13,7 @@ describe('meter (smoke test)', function () { }); it('record once and get count should return 1', function () { - var meter; - meter = new statman.Meter(); + const meter = new statman.Meter(); meter.record(); meter.getCount().should.be.equal(1); }); From cdcb6a75fd28a09f4f57a5996e5425fb783c8397 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:24:45 -0400 Subject: [PATCH 37/51] var/const cleanup --- test/meter-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index 2766995..027d142 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -19,8 +19,7 @@ describe('meter (smoke test)', function () { }); it('record and read', function () { - var meter; - meter = new statman.Meter(); + const meter = new statman.Meter(); meter.record(1000); meter.record(2000); meter.getAverage().should.equal(1500); From 6fdde598f0e862a4e16d8e5897752e6f181134f0 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:00 -0400 Subject: [PATCH 38/51] var/const cleanup --- test/meter-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index 027d142..dc29669 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -27,9 +27,9 @@ describe('meter (smoke test)', function () { }); it('meter.start() provides an event, which can be used to auto record meter', function (done) { - var meter = new statman.Meter(); + const meter = new statman.Meter(); - var meterEvent = meter.startEvent(); + const meterEvent = meter.startEvent(); setTimeout(function () { meterEvent.stop(); From 9803e02b7a6ab8872b31f41f3e8076c3d73c1ec9 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:06 -0400 Subject: [PATCH 39/51] var/const cleanup --- test/meter-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/meter-test.js b/test/meter-test.js index dc29669..b561733 100644 --- a/test/meter-test.js +++ b/test/meter-test.js @@ -41,8 +41,7 @@ describe('meter (smoke test)', function () { }); it('toString()', function () { - var meter; - meter = new statman.Meter(); + const meter = new statman.Meter(); meter.record(2.2); meter.record(4.4); meter.toString().should.equal('[count:2; average:3.30]'); From 6310b3431ff6ddd57e69a86cafb9931c50bc64ab Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:21 -0400 Subject: [PATCH 40/51] var/const cleanup --- test/statman-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statman-test.js b/test/statman-test.js index 377f369..299c3ed 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -1,4 +1,4 @@ -var statman = require('../lib/statman'); +const statman = require('../lib/statman'); var assert = require('assert'); var should = require('should'); From 861332271dcd32841038dc487b65913c2c53c312 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:27 -0400 Subject: [PATCH 41/51] var/const cleanup --- test/statman-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statman-test.js b/test/statman-test.js index 299c3ed..09ae835 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -1,5 +1,5 @@ const statman = require('../lib/statman'); -var assert = require('assert'); +const assert = require('assert'); var should = require('should'); describe('registry', function () { From af3bd7d5083214b6133e373dc0eed5f9f4748547 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:30 -0400 Subject: [PATCH 42/51] var/const cleanup --- test/statman-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statman-test.js b/test/statman-test.js index 09ae835..b4956c3 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -1,6 +1,6 @@ const statman = require('../lib/statman'); const assert = require('assert'); -var should = require('should'); +const should = require('should'); describe('registry', function () { beforeEach(function () { From aced7a4157ed6e1caa71addc84c5d88793986d50 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:25:54 -0400 Subject: [PATCH 43/51] var/const cleanup --- test/statman-test.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/statman-test.js b/test/statman-test.js index b4956c3..4de9713 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -8,9 +8,9 @@ describe('registry', function () { }); it('registry() => returns full list of metrics', function () { - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); @@ -18,9 +18,9 @@ describe('registry', function () { }); it('registry(name) => returns single item', function () { - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); @@ -30,11 +30,11 @@ describe('registry', function () { }); it('registry can have key passed explicitly', function () { - var metric = {value: 'abc'}; + const metric = {value: 'abc'}; - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); @@ -44,11 +44,11 @@ describe('registry', function () { }); it('registry can have key discovered from name', function () { - var metric = {name: 'x'}; + const metric = {name: 'x'}; - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); From de3381bb61a6bbec594f4bf6ae6745ecb4882eac Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:26:03 -0400 Subject: [PATCH 44/51] var/const cleanup --- test/statman-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/statman-test.js b/test/statman-test.js index 4de9713..7766a3b 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -58,15 +58,15 @@ describe('registry', function () { }); it('registry can have key discovered from name()', function () { - var metric = { + const metric = { name: function () { return 'x' } }; - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); From 73f1fb589826fd2439504ab6cc34ed6217bd580f Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:26:23 -0400 Subject: [PATCH 45/51] var/const cleanup --- test/statman-test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/statman-test.js b/test/statman-test.js index 7766a3b..8361c41 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -76,15 +76,15 @@ describe('registry', function () { }); it('registry can have key discovered from getName()', function () { - var metric = { + const metric = { getName: function () { return 'x' } }; - var metricA = {name: 'metricA'}; - var metricB = {name: 'metricB'}; - var metricC = {name: 'metric-C'}; + const metricA = {name: 'metricA'}; + const metricB = {name: 'metricB'}; + const metricC = {name: 'metric-C'}; statman.register(metricA); statman.register(metricB); statman.register(metricC); @@ -94,12 +94,12 @@ describe('registry', function () { }); it('registering metric with same name overwrites the first', function () { - var metricA = { + const metricA = { name: function () { return 'metric-a' }, value: 1 }; - var metricB = { + const metricB = { name: function () { return 'metric-a' }, value: 2 From 46343f4163bbd78e9a162ef08d4fdb03b13ca202 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:26:31 -0400 Subject: [PATCH 46/51] var/const cleanup --- test/statman-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/statman-test.js b/test/statman-test.js index 8361c41..fed799d 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -126,12 +126,12 @@ describe('registry', function () { describe('gauge in registry', function () { it('get new instance of a gauge', function () { - var gauge = statman.gauge('metric-name'); + const gauge = statman.gauge('metric-name'); gauge.name().should.equal('metric-name'); }); it('explicit register gauge', function () { - var gauge = new statman.Gauge('metric-name'); + const gauge = new statman.Gauge('metric-name'); should.not.exist(statman.registry('metric-name')); statman.register(gauge); should.exist(statman.registry('metric-name')); From 3e03288668711e2205b49ce57be9bb8081bc9331 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:26:38 -0400 Subject: [PATCH 47/51] var/const cleanup --- test/statman-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statman-test.js b/test/statman-test.js index fed799d..2cb8936 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -155,7 +155,7 @@ describe('registry', function () { describe('meter in registry', function () { it('get new instance of a meter', function () { - var meter = statman.meter('metric-name'); + const meter = statman.meter('metric-name'); meter.name().should.equal('metric-name'); }); From d5977d6183697fd77c94eaf32052f11d74524637 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:26:41 -0400 Subject: [PATCH 48/51] var/const cleanup --- test/statman-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statman-test.js b/test/statman-test.js index 2cb8936..6922e40 100644 --- a/test/statman-test.js +++ b/test/statman-test.js @@ -160,7 +160,7 @@ describe('registry', function () { }); it('explicit register meter', function () { - var meter = new statman.Meter('metric-name'); + const meter = new statman.Meter('metric-name'); should.not.exist(statman.registry('metric-name')); statman.register(meter); should.exist(statman.registry('metric-name')); From 9636559494a5a9cbb2ff3b39a20c4f08ea5f1074 Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:27:21 -0400 Subject: [PATCH 49/51] var/const cleanup --- test/stopwatch-test.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/stopwatch-test.js b/test/stopwatch-test.js index 84b60f7..4dee061 100644 --- a/test/stopwatch-test.js +++ b/test/stopwatch-test.js @@ -12,53 +12,53 @@ describe('stopwatch (smoke test)', function () { statman.reset(); }); it('explicit constructor', function () { - var stopwatch = new statman.Stopwatch('metric-name'); + const stopwatch = new statman.Stopwatch('metric-name'); should.exists(stopwatch); }); it('explicit constructor (w/no name or autostart)', function () { - var stopwatch = new statman.Stopwatch(); + const stopwatch = new statman.Stopwatch(); should.exist(stopwatch.name()); }); it('explicit constructor (w/autostart)', function () { - var stopwatch = new statman.Stopwatch(true); + const stopwatch = new statman.Stopwatch(true); should.exist(stopwatch.name()); stopwatch.name().should.not.equal(true); }); it('explicit constructor (w/name and autostart)', function () { - var stopwatch = new statman.Stopwatch('metric-name', true); + const stopwatch = new statman.Stopwatch('metric-name', true); should.exist(stopwatch.name()); stopwatch.name().should.equal('metric-name'); }); it('implicit constructor', function () { - var stopwatch = statman.stopwatch('metric-name'); + const stopwatch = statman.stopwatch('metric-name'); should.exists(stopwatch); }); it('implicit constructor w/no name', function () { - var stopwatch = statman.stopwatch(); + const stopwatch = statman.stopwatch(); should.exists(stopwatch); should.exist(stopwatch.name()); }); it('name', function () { - var stopwatch = new statman.Stopwatch('metric-name'); + const stopwatch = new statman.Stopwatch('metric-name'); assert.equal('metric-name', stopwatch.name()); }); it('access via registry', function () { - var stopwatch = statman.stopwatch('metric-name'); + const stopwatch = statman.stopwatch('metric-name'); statman.registry('metric-name').start(); statman.registry('metric-name').stop(); }); it('start and read (10ms)', function (done) { - var testtime = 10; + const testtime = 10; - var stopwatch = new statman.Stopwatch(); + const stopwatch = new statman.Stopwatch(); stopwatch.start(); setTimeout(function () { var delta = stopwatch.read(); @@ -68,9 +68,9 @@ describe('stopwatch (smoke test)', function () { }); it('autostart and read (10ms)', function (done) { - var testtime = 10; + const testtime = 10; - var stopwatch = new statman.Stopwatch(true); + const stopwatch = new statman.Stopwatch(true); setTimeout(function () { var delta = stopwatch.read(); verifyDelta(testtime, delta, 10); @@ -80,20 +80,20 @@ describe('stopwatch (smoke test)', function () { describe('toString()', function () { it('idle', function () { - var stopwatch = statman.stopwatch('sw'); + const stopwatch = statman.stopwatch('sw'); //[sw => state:init; value:NaN] stopwatch.toString().should.containEql('state:init'); stopwatch.toString().should.containEql('value:'); }); it('started', function () { - var stopwatch = statman.stopwatch('sw'); + const stopwatch = statman.stopwatch('sw'); stopwatch.start(); //[sw => state:running; value:0.01] stopwatch.toString().should.containEql('state:running'); stopwatch.toString().should.containEql('value:'); }); it('stopped', function () { - var stopwatch = statman.stopwatch('sw'); + const stopwatch = statman.stopwatch('sw'); stopwatch.start(); stopwatch.stop(); //[sw => state:stopped; value:0.01] From 1be10870192f518cddffd02c5ad00a4b443aca5e Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:27:34 -0400 Subject: [PATCH 50/51] var/const cleanup --- test/testhelper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testhelper.js b/test/testhelper.js index d5df668..49ce656 100644 --- a/test/testhelper.js +++ b/test/testhelper.js @@ -3,9 +3,9 @@ const isNull = require('lodash.isnull'); function assertCloseEnough(actual, expected, acceptedVariance) { if (isNull(acceptedVariance)) acceptedVariance = 10; - var lowerThreshold = expected - acceptedVariance; - var upperThreshold = expected + acceptedVariance; - var message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; + const lowerThreshold = expected - acceptedVariance; + const upperThreshold = expected + acceptedVariance; + const message = "Expected " + expected + " ± " + acceptedVariance + ", was " + actual + "."; assert.ok((actual >= lowerThreshold) && (actual <= upperThreshold), message); } From 0e63495a59966ea85fe6ac8c20022f806f13b30b Mon Sep 17 00:00:00 2001 From: Jason Ray Date: Thu, 5 Apr 2018 22:27:56 -0400 Subject: [PATCH 51/51] update version to 1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8e66894..fd7e4e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "statman", - "version": "1.3.0", + "version": "1.4.0", "description": "Package to assist with collection of metrics, including stopwatch functionality", "main": "./lib/statman.js", "scripts": {