Skip to content

Commit

Permalink
Replace lodash.pick (#2237)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Dec 30, 2024
1 parent 87d0db5 commit e41d1e2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/chrome/webdriver/builder.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/edge/webdriver/builder.js
Original file line number Diff line number Diff line change
@@ -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 || {};
Expand Down
3 changes: 1 addition & 2 deletions lib/firefox/webdriver/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion lib/support/har/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions lib/support/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e41d1e2

Please sign in to comment.