Skip to content

Commit d1223a4

Browse files
committed
Fix tests
1 parent 8b15f1a commit d1223a4

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

packages/database/src/core/snap/nodeFromJSON.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export function nodeFromJSON(
7070
const children: NamedNode[] = [];
7171
let childrenHavePriority = false;
7272
const hinzeJsonObj: { [k: string]: any } = json;
73-
each(hinzeJsonObj, (key: string, child: any) => {
74-
if (typeof key !== 'string' || key.substring(0, 1) !== '.') {
73+
each(hinzeJsonObj, (key, child) => {
74+
if (key.substring(0, 1) !== '.') {
7575
// Ignore metadata nodes
7676
const childNode = nodeFromJSON(child);
7777
if (!childNode.isEmpty()) {

packages/database/src/core/util/util.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,16 @@ export const splitStringBySize = function(
394394
* @param obj The object or array to iterate over
395395
* @param fn The function to apply
396396
*/
397-
export function each(obj: object | Array<any>, fn: (v: any, k: any) => void) {
398-
if (Array.isArray(obj)) {
399-
for (let i = 0; i < obj.length; ++i) {
400-
fn(i, obj[i]);
401-
}
402-
} else {
403-
/**
404-
* in the conversion of code we removed the goog.object.forEach
405-
* function which did a value,key callback. We standardized on
406-
* a single impl that does a key, value callback. So we invert
407-
* to not have to touch the `each` code points
408-
*/
409-
for (const key in obj) {
410-
if (obj.hasOwnProperty(key)) {
411-
fn(obj[key], key);
412-
}
397+
export function each(obj: object, fn: (k: string, v: any) => void) {
398+
/**
399+
* in the conversion of code we removed the goog.object.forEach
400+
* function which did a value,key callback. We standardized on
401+
* a single impl that does a key, value callback. So we invert
402+
* to not have to touch the `each` code points
403+
*/
404+
for (const key in obj) {
405+
if (obj.hasOwnProperty(key)) {
406+
fn(key, obj[key]);
413407
}
414408
}
415409
}

packages/database/src/realtime/TransportManager.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,11 @@ export class TransportManager {
7070
this.transports_ = [WebSocketConnection];
7171
} else {
7272
const transports = (this.transports_ = [] as TransportConstructor[]);
73-
each(
74-
TransportManager.ALL_TRANSPORTS,
75-
(i: number, transport: TransportConstructor) => {
76-
if (transport && transport['isAvailable']()) {
77-
transports.push(transport);
78-
}
73+
for (const transport of TransportManager.ALL_TRANSPORTS) {
74+
if (transport && transport['isAvailable']()) {
75+
transports.push(transport);
7976
}
80-
);
77+
}
8178
}
8279
}
8380

0 commit comments

Comments
 (0)