Skip to content

Commit 4c2f8d1

Browse files
Cleanup: Use Object.assign() to create shallow copies (#2647)
1 parent 1a7ef72 commit 4c2f8d1

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

packages/firestore/src/util/api.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ export function makeConstructorPrivate<T extends Function>(
4646
PublicConstructor.prototype = cls.prototype;
4747

4848
// Copy any static methods/members
49-
for (const staticProperty in cls) {
50-
if (cls.hasOwnProperty(staticProperty)) {
51-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
52-
(PublicConstructor as any)[staticProperty] = (cls as any)[staticProperty];
53-
}
54-
}
49+
Object.assign(PublicConstructor, cls);
50+
5551
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5652
return PublicConstructor as any;
5753
}

packages/firestore/src/util/obj.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,5 @@ export function shallowCopy<V>(obj: Dict<V>): Dict<V> {
105105
obj && typeof obj === 'object',
106106
'shallowCopy() expects object parameter.'
107107
);
108-
const result: Dict<V> = {};
109-
for (const key in obj) {
110-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
111-
result[key] = obj[key];
112-
}
113-
}
114-
return result;
108+
return { ...obj };
115109
}

0 commit comments

Comments
 (0)