Skip to content

Commit ff1698b

Browse files
committed
Used lodash operator
1 parent 19df4cd commit ff1698b

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

packages/database/test/helpers/syncpoint-util.ts

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import assert from 'assert';
2020
import { FirebaseApp, initializeApp } from '@firebase/app';
2121
import { expect } from 'chai';
2222
import * as chai from 'chai';
23+
import _ from 'lodash';
2324
import sinonChai from 'sinon-chai';
2425

2526
import {
@@ -72,37 +73,6 @@ function objectMap(object, mapFn) {
7273
return newObj;
7374
}
7475

75-
function unsafeClone(obj) {
76-
if (!obj || typeof obj !== 'object') {
77-
return obj;
78-
}
79-
if (typeof obj.clone === 'function') {
80-
return obj.clone();
81-
}
82-
if (typeof Map !== 'undefined' && obj instanceof Map) {
83-
return new Map(obj);
84-
} else if (typeof Set !== 'undefined' && obj instanceof Set) {
85-
return new Set(obj);
86-
} else if (obj instanceof Date) {
87-
return new Date(obj.getTime());
88-
}
89-
const clone = Array.isArray(obj)
90-
? []
91-
: typeof ArrayBuffer === 'function' &&
92-
typeof ArrayBuffer.isView === 'function' &&
93-
ArrayBuffer.isView(obj) &&
94-
!(obj instanceof DataView)
95-
? // @ts-ignore
96-
new obj.constructor(obj.length)
97-
: {};
98-
99-
// eslint-disable-next-line guard-for-in
100-
for (const key in obj) {
101-
clone[key] = unsafeClone(obj[key]);
102-
}
103-
return clone;
104-
}
105-
10676
// eslint-disable-next-line @typescript-eslint/ban-types
10777
function removeIf<T>(array: T[], callback: Function) {
10878
let i = 0;
@@ -435,8 +405,8 @@ export class SyncPointTestParser {
435405
const registrations = {};
436406

437407
for (let i = 0; i < testSpec.steps.length; ++i) {
438-
// TODO: Create a separate object structure specifically for the steps.
439-
const spec = unsafeClone(testSpec.steps[i]);
408+
// TODO: Create a separate object structure specifically for the steps
409+
const spec = _.cloneDeep(testSpec.steps[i]);
440410
if ('.comment' in spec) {
441411
console.log(' > ' + spec['.comment']);
442412
}

0 commit comments

Comments
 (0)