From e41d1e2657fd6c485ac5650653b841e479917007 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Mon, 30 Dec 2024 09:11:36 +0100 Subject: [PATCH] Replace lodash.pick (#2237) --- lib/chrome/webdriver/builder.js | 2 +- lib/edge/webdriver/builder.js | 2 +- lib/firefox/webdriver/builder.js | 3 +-- lib/support/har/index.js | 2 +- lib/support/util.js | 13 +++++++++++++ package-lock.json | 11 ----------- package.json | 1 - 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/chrome/webdriver/builder.js b/lib/chrome/webdriver/builder.js index 40b89f23ad..d78e06703c 100644 --- a/lib/chrome/webdriver/builder.js +++ b/lib/chrome/webdriver/builder.js @@ -1,10 +1,10 @@ -import pick from 'lodash.pick'; import isEmpty from 'lodash.isempty'; import get from 'lodash.get'; import { logging } from 'selenium-webdriver'; import { ServiceBuilder, Options } from 'selenium-webdriver/chrome.js'; import { pac, manual } from 'selenium-webdriver/proxy.js'; import { setupChromiumOptions } from './setupChromiumOptions.js'; +import { pick } from '../../support/util.js'; /** * Configure a WebDriver builder based on the specified options. diff --git a/lib/edge/webdriver/builder.js b/lib/edge/webdriver/builder.js index 1f75619dfb..3bd6160b35 100644 --- a/lib/edge/webdriver/builder.js +++ b/lib/edge/webdriver/builder.js @@ -1,12 +1,12 @@ import { Options, ServiceBuilder } from 'selenium-webdriver/edge.js'; import intel from 'intel'; import get from 'lodash.get'; -import pick from 'lodash.pick'; import isEmpty from 'lodash.isempty'; import { logging } from 'selenium-webdriver'; import { setupChromiumOptions } from '../../chrome/webdriver/setupChromiumOptions.js'; const log = intel.getLogger('browsertime.edge'); const { pac, manual } = 'selenium-webdriver/proxy.js'; +import { pick } from '../../support/util.js'; export async function configureBuilder(builder, baseDir, options) { const edgeConfig = options.edge || {}; diff --git a/lib/firefox/webdriver/builder.js b/lib/firefox/webdriver/builder.js index d1eac8fcfe..508cac1857 100644 --- a/lib/firefox/webdriver/builder.js +++ b/lib/firefox/webdriver/builder.js @@ -6,13 +6,12 @@ import { } from 'selenium-webdriver/firefox.js'; import intel from 'intel'; import { pac, manual } from 'selenium-webdriver/proxy.js'; -import pick from 'lodash.pick'; import isEmpty from 'lodash.isempty'; import get from 'lodash.get'; import { defaultFirefoxPreferences } from '../settings/firefoxPreferences.js'; import { disableSafeBrowsingPreferences } from '../settings/disableSafeBrowsingPreferences.js'; import { disableTrackingProtectionPreferences } from '../settings/disableTrackingProtectionPreferences.js'; -import { toArray } from '../../support/util.js'; +import { toArray, pick } from '../../support/util.js'; import { Android, isAndroidConfigured } from '../../android/index.js'; const log = intel.getLogger('browsertime.firefox'); diff --git a/lib/support/har/index.js b/lib/support/har/index.js index 0e0dfdff54..16ae914e4e 100644 --- a/lib/support/har/index.js +++ b/lib/support/har/index.js @@ -1,6 +1,5 @@ import { createRequire } from 'node:module'; import merge from 'lodash.merge'; -import pick from 'lodash.pick'; import isEmpty from 'lodash.isempty'; import get from 'lodash.get'; import { pathToFolder } from '../pathToFolder.js'; @@ -9,6 +8,7 @@ import intel from 'intel'; const log = intel.getLogger('browsertime'); const require = createRequire(import.meta.url); const version = require('../../../package.json').version; +import { pick } from '../../support/util.js'; function generateUniquePageId(baseId, existingIdMap) { let newId = baseId; diff --git a/lib/support/util.js b/lib/support/util.js index b31312a463..5b674aa06b 100644 --- a/lib/support/util.js +++ b/lib/support/util.js @@ -286,3 +286,16 @@ export function localTime() { return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${sign}${offsetHours}:${offsetMinutes}`; } + +export function pick(obj, keys) { + const result = {}; + if (!obj || typeof obj !== 'object') { + return result; + } + for (const key of keys) { + if (key in obj) { + result[key] = obj[key]; + } + } + return result; +} diff --git a/package-lock.json b/package-lock.json index ca91767a26..d0d6097e44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "lodash.groupby": "4.6.0", "lodash.isempty": "4.4.0", "lodash.merge": "4.6.2", - "lodash.pick": "4.4.0", "lodash.set": "4.3.2", "selenium-webdriver": "4.27.0", "usb-power-profiling": "1.5.0", @@ -4821,11 +4820,6 @@ "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" }, - "node_modules/lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=" - }, "node_modules/lodash.set": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", @@ -11052,11 +11046,6 @@ "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" }, - "lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=" - }, "lodash.set": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", diff --git a/package.json b/package.json index f4c42267fc..fd796b94ce 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "lodash.groupby": "4.6.0", "lodash.isempty": "4.4.0", "lodash.merge": "4.6.2", - "lodash.pick": "4.4.0", "lodash.set": "4.3.2", "selenium-webdriver": "4.27.0", "usb-power-profiling": "1.5.0",