Skip to content

Commit 6daf09c

Browse files
dev dependency update: eslint (major) (#30)
* dev dependency eslint updated to version 8.57.0 * chore: fix lint * chore: update tap parameters --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: William Killerud <[email protected]>
1 parent 3cd4d83 commit 6daf09c

File tree

7 files changed

+698
-648
lines changed

7 files changed

+698
-648
lines changed

.eslintrc

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
{
2-
"env": {
3-
"es6": true,
4-
"node": true
5-
},
6-
"extends": "airbnb-base",
7-
"rules": {
8-
"strict": [0, "global"],
9-
"prefer-const": 1,
10-
"indent": [1, 4],
11-
"class-methods-use-this": [0],
12-
"import/no-extraneous-dependencies": [0],
13-
"arrow-body-style": [0, "always"],
14-
"no-multiple-empty-lines": [0],
15-
"no-underscore-dangle": [0],
16-
"comma-dangle": [0],
17-
"no-plusplus": [0],
18-
"no-console": [0],
19-
"new-cap": [0]
20-
}
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
3+
"plugins": ["prettier"],
4+
"env": { "es6": true, "node": true },
5+
"parserOptions": {
6+
"requireConfigFile": false,
7+
"ecmaVersion": 2020,
8+
"sourceType": "module"
9+
}
2110
}

.prettierrc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
2-
"singleQuote": true,
3-
"trailingComma": "all",
4-
"tabWidth": 4
2+
"singleQuote": false,
3+
"trailingComma": "all",
4+
"useTabs": true,
5+
"printWidth": 120,
6+
"overrides": [
7+
{
8+
"files": ["*.yml"],
9+
"options": {
10+
"tabWidth": 2,
11+
"useTabs": false
12+
}
13+
}
14+
]
515
}

benchmark/benchmark.js

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,86 @@
1-
'use strict';
1+
"use strict";
22

3-
/* eslint no-unused-vars: "off", import/no-extraneous-dependencies: "off", no-console: "off" */
4-
5-
const benchmark = require('fastbench');
6-
const stream = require('readable-stream');
7-
const Metric = require('@metrics/metric');
8-
const Guard = require('../');
3+
const benchmark = require("fastbench");
4+
const stream = require("readable-stream");
5+
const Metric = require("@metrics/metric");
6+
const Guard = require("..");
97

108
const srcObjectStream = () => {
11-
return new stream.Readable({
12-
objectMode: true,
13-
read() {
14-
15-
}
16-
});
9+
return new stream.Readable({
10+
objectMode: true,
11+
read() {},
12+
});
1713
};
1814

1915
const destObjectStream = (done) => {
20-
const dStream = new stream.Writable({
21-
objectMode: true,
22-
write(chunk, encoding, callback) {
23-
callback();
24-
},
25-
});
26-
dStream.on('finish', done);
27-
return dStream;
16+
const dStream = new stream.Writable({
17+
objectMode: true,
18+
write(chunk, encoding, callback) {
19+
callback();
20+
},
21+
});
22+
dStream.on("finish", done);
23+
return dStream;
2824
};
2925

3026
const iterations = 10;
3127
const max = 100000;
3228

33-
const run = benchmark([
34-
function NonGuardedMetricStream(done) {
35-
const guard = new Guard({ enabled: false, permutationThreshold: (max + 1) });
36-
const dest = destObjectStream(done);
37-
const src = srcObjectStream();
38-
39-
src.pipe(guard).pipe(dest);
40-
41-
for (let i = 0; i < max; i++) {
42-
const metric = new Metric({ name: 'foo', description: 'foo', labels: [{ name: 'foo', value: i }] });
43-
src.push(metric);
44-
}
45-
46-
process.nextTick(() => {
47-
src.push(null);
48-
});
49-
},
50-
51-
function GuardedMetricStreamNoDrop(done) {
52-
const guard = new Guard({ enabled: true, permutationThreshold: (max * 2) });
53-
const dest = destObjectStream(done);
54-
const src = srcObjectStream();
55-
56-
src.pipe(guard).pipe(dest);
57-
58-
for (let i = 0; i < max; i++) {
59-
const metric = new Metric({ name: 'foo', description: 'foo', labels: [{ name: 'foo', value: i }] });
60-
src.push(metric);
61-
}
62-
63-
process.nextTick(() => {
64-
src.push(null);
65-
});
66-
},
67-
68-
function GuardedMetricStreamDropping(done) {
69-
const guard = new Guard({ enabled: true, permutationThreshold: 10000 });
70-
const dest = destObjectStream(done);
71-
const src = srcObjectStream();
72-
73-
src.pipe(guard).pipe(dest);
74-
75-
for (let i = 0; i < max; i++) {
76-
const metric = new Metric({ name: 'foo', description: 'foo', labels: [{ name: 'foo', value: i }] });
77-
src.push(metric);
78-
}
79-
80-
process.nextTick(() => {
81-
src.push(null);
82-
});
83-
},
84-
], iterations);
29+
const run = benchmark(
30+
[
31+
function NonGuardedMetricStream(done) {
32+
const guard = new Guard({ enabled: false, permutationThreshold: max + 1 });
33+
const dest = destObjectStream(done);
34+
const src = srcObjectStream();
35+
36+
src.pipe(guard).pipe(dest);
37+
38+
for (let i = 0; i < max; i++) {
39+
const metric = new Metric({ name: "foo", description: "foo", labels: [{ name: "foo", value: i }] });
40+
src.push(metric);
41+
}
42+
43+
process.nextTick(() => {
44+
src.push(null);
45+
});
46+
},
47+
48+
function GuardedMetricStreamNoDrop(done) {
49+
const guard = new Guard({ enabled: true, permutationThreshold: max * 2 });
50+
const dest = destObjectStream(done);
51+
const src = srcObjectStream();
52+
53+
src.pipe(guard).pipe(dest);
54+
55+
for (let i = 0; i < max; i++) {
56+
const metric = new Metric({ name: "foo", description: "foo", labels: [{ name: "foo", value: i }] });
57+
src.push(metric);
58+
}
59+
60+
process.nextTick(() => {
61+
src.push(null);
62+
});
63+
},
64+
65+
function GuardedMetricStreamDropping(done) {
66+
const guard = new Guard({ enabled: true, permutationThreshold: 10000 });
67+
const dest = destObjectStream(done);
68+
const src = srcObjectStream();
69+
70+
src.pipe(guard).pipe(dest);
71+
72+
for (let i = 0; i < max; i++) {
73+
const metric = new Metric({ name: "foo", description: "foo", labels: [{ name: "foo", value: i }] });
74+
src.push(metric);
75+
}
76+
77+
process.nextTick(() => {
78+
src.push(null);
79+
});
80+
},
81+
],
82+
iterations,
83+
);
8584

8685
// run them two times
8786
console.log(`Push ${max * iterations} metric objects through metric stream:`);

0 commit comments

Comments
 (0)