Skip to content

Commit c737ee0

Browse files
authored
Stop depending on lodash groupby, difference and times (#11428)
1 parent a2edbf5 commit c737ee0

File tree

5 files changed

+11
-31
lines changed

5 files changed

+11
-31
lines changed

core/server/metrics/format-converters.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import groupBy from 'lodash.groupby'
2-
31
function promClientJsonToInfluxV2(metrics, extraLabels = {}) {
42
return metrics
53
.flatMap(metric => {
6-
const valuesByLabels = groupBy(metric.values, value =>
7-
JSON.stringify(Object.entries(value.labels).sort()),
8-
)
4+
const valuesByLabels = metric.values.reduce((acc, value) => {
5+
const key = JSON.stringify(Object.entries(value.labels).sort())
6+
if (!acc[key]) {
7+
acc[key] = []
8+
}
9+
acc[key].push(value)
10+
return acc
11+
}, {})
912
return Object.values(valuesByLabels).map(metricsWithSameLabel => {
1013
const labels = Object.entries(metricsWithSameLabel[0].labels)
1114
.concat(Object.entries(extraLabels))

core/service-test-runner/services-for-title.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* @module
33
*/
44

5-
import difference from 'lodash.difference'
6-
75
/**
86
* Given a pull request title like
97
* '[Travis Sonar] Support user token authentication'
@@ -27,7 +25,7 @@ function servicesForTitle(title) {
2725
services = services.filter(Boolean).map(service => service.toLowerCase())
2826

2927
const ignored = ['wip', 'rfc', 'security']
30-
return difference(services, ignored)
28+
return services.filter(service => !ignored.includes(service))
3129
}
3230

3331
export default servicesForTitle

core/token-pooling/token-pool.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { expect } from 'chai'
22
import sinon from 'sinon'
3-
import times from 'lodash.times'
43
import { Token, TokenPool } from './token-pool.js'
54

5+
const times = (n, fn) => [...Array(n)].map(() => fn())
6+
67
function expectPoolToBeExhausted(pool) {
78
expect(() => {
89
pool.next()

package-lock.json

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
"js-yaml": "^4.1.0",
5151
"jsonpath-plus": "^10.3.0",
5252
"lodash.countby": "^4.6.0",
53-
"lodash.groupby": "^4.6.0",
54-
"lodash.times": "^4.3.2",
5553
"matcher": "^6.0.0",
5654
"mvncmp": "^1.0.0",
5755
"node-env-flag": "^0.1.0",
@@ -184,7 +182,6 @@
184182
"is-svg": "^6.1.0",
185183
"jsdoc": "^4.0.4",
186184
"lint-staged": "^16.2.3",
187-
"lodash.difference": "^4.5.0",
188185
"minimist": "^1.2.8",
189186
"mocha": "^11.7.3",
190187
"mocha-env-reporter": "^4.0.0",

0 commit comments

Comments
 (0)