Skip to content

Commit bd23960

Browse files
committed
Addressed comments
1 parent 31a747e commit bd23960

File tree

1 file changed

+12
-1
lines changed
  • packages/database/test/helpers

1 file changed

+12
-1
lines changed

packages/database/test/helpers/util.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { v4 as uuidv4 } from 'uuid';
1918

2019
import { Database, ref } from '../../src';
2120
import { ConnectionTarget } from '../../src/api/test_access';
@@ -80,6 +79,18 @@ export function waitFor(waitTimeInMS: number) {
8079
return new Promise(resolve => setTimeout(resolve, waitTimeInMS));
8180
}
8281

82+
/**
83+
* Copied from https://stackoverflow.com/a/2117523
84+
* TODO: extract this into @firebase/util
85+
*/
86+
export function uuidv4(): string {
87+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
88+
const r = (Math.random() * 16) | 0,
89+
v = c === 'x' ? r : (r & 0x3) | 0x8;
90+
return v.toString(16);
91+
});
92+
}
93+
8394
// Creates a unique reference using uuid
8495
export function getUniqueRef(db: Database) {
8596
const path = uuidv4();

0 commit comments

Comments
 (0)