Skip to content

Commit 025cc9a

Browse files
authored
Merge pull request #20188 from mozilla/lodash-pick-native
chore(): replace lodash.pick with native code
2 parents 303a98f + 41d8077 commit 025cc9a

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

packages/fxa-shared/metrics/amplitude.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
import Ajv from 'ajv';
6-
import pick from 'lodash.pick';
76
import {
87
ParsedUserAgentProperties,
98
ParsedUa,
@@ -184,7 +183,11 @@ function mapSubscriptionEventProperties(
184183
'subscription_id',
185184
'voluntary_cancellation',
186185
];
187-
return pick(data, keys);
186+
const result: EventData = {};
187+
for (const k of keys) {
188+
if (k in data) result[k] = data[k];
189+
}
190+
return result;
188191
}
189192

190193
return;

packages/fxa-shared/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@
294294
"knex": "^3.1.0",
295295
"lodash.clonedeep": "^4.5.0",
296296
"lodash.omitby": "^4.6.0",
297-
"lodash.pick": "^4.4.0",
298297
"moment": "^2.30.1",
299298
"mozlog": "^3.0.2",
300299
"mysql": "^2.18.1",

packages/fxa-shared/subscriptions/stripe.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Stripe from 'stripe';
2-
import pick from 'lodash.pick';
32
import omitBy from 'lodash.omitby';
43
import {
54
Plan,
@@ -12,6 +11,15 @@ import { productUpgradeFromProductConfig } from './configuration/utils';
1211
const isCapabilityKey = (value: string, key: string) =>
1312
key.startsWith('capabilities');
1413

14+
const pick = (obj: any, ...keys: string[]): any => {
15+
if (obj == null) return {};
16+
const result: any = {};
17+
for (const k of keys) {
18+
if (k in obj) result[k] = obj[k];
19+
}
20+
return result;
21+
};
22+
1523
export type DeepPartial<T> = {
1624
[P in keyof T]?: DeepPartial<T[P]>;
1725
};
@@ -67,7 +75,7 @@ export function filterCustomer(
6775
'default_payment_method'
6876
) as any;
6977
if (customer.sources?.data) {
70-
customer.sources.data = customer.sources.data.map((s) =>
78+
customer.sources.data = customer.sources.data.map((s: any) =>
7179
pick(s, 'id', 'object', 'brand', 'exp_month', 'exp_year', 'last4')
7280
) as any;
7381
customer.sources = pick(customer.sources, 'data') as any;

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36792,7 +36792,6 @@ __metadata:
3679236792
knex: "npm:^3.1.0"
3679336793
lodash.clonedeep: "npm:^4.5.0"
3679436794
lodash.omitby: "npm:^4.6.0"
36795-
lodash.pick: "npm:^4.4.0"
3679636795
mocha: "npm:^10.4.0"
3679736796
moment: "npm:^2.30.1"
3679836797
mozlog: "npm:^3.0.2"
@@ -44101,13 +44100,6 @@ __metadata:
4410144100
languageName: node
4410244101
linkType: hard
4410344102

44104-
"lodash.pick@npm:^4.4.0":
44105-
version: 4.4.0
44106-
resolution: "lodash.pick@npm:4.4.0"
44107-
checksum: 10c0/a04c460b95d1aaa44e9513d1dacf72ea74d838da843e45831de9de64c303f13cdde1859702a6f4dcef417816898ffd47c6ae0614c957ac70245bed2809b8d2e2
44108-
languageName: node
44109-
linkType: hard
44110-
4411144103
"lodash.snakecase@npm:^4.1.1":
4411244104
version: 4.1.1
4411344105
resolution: "lodash.snakecase@npm:4.1.1"

0 commit comments

Comments
 (0)