Skip to content

Commit 3d1862e

Browse files
authored
Merge pull request #598 from neo4j/more-code-cleanup
Minor improvements on code
2 parents e04fefb + da8e7f1 commit 3d1862e

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

src/expressions/map/MapExpr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export class MapExpr implements CypherCompilable {
4242
if (typeof keyOrValues === "string") {
4343
this.setField(keyOrValues, value);
4444
} else {
45-
Object.entries(keyOrValues).forEach(([key, value]) => {
45+
for (const [key, value] of Object.entries(keyOrValues)) {
4646
this.setField(key, value);
47-
});
47+
}
4848
}
4949
}
5050

src/expressions/map/MapProjection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export class MapProjection implements CypherCompilable {
101101
}
102102

103103
private setExtraValues(values: Record<string, Expr>): void {
104-
Object.entries(values).forEach(([key, value]) => {
104+
for (const [key, value] of Object.entries(values)) {
105105
if (!value) throw new Error(`Missing value on map key ${key}`);
106106
this.extraValues.set(key, value);
107-
});
107+
}
108108
}
109109
}

src/namespaces/apoc/cypher/run-first-column.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class RunFirstColumnFunction extends CypherFunction {
8585
}
8686

8787
private escapeQuery(query: string): string {
88-
return query.replace(/(["\\])/g, "\\$1");
88+
return query.replaceAll(/(["\\])/g, "\\$1");
8989
}
9090

9191
private parseVariablesInput(variables: Variable[] | MapExpr | Record<string, Expr>): Variable[] | MapExpr {

src/references/Variable.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ export class Variable {
3131
/**
3232
* @internal
3333
*/
34-
public prefix: string;
35-
36-
constructor() {
37-
this.prefix = "var";
38-
}
34+
public prefix: string = "var";
3935

4036
/** Access individual property via the PropertyRef class */
4137
public property(...path: Array<string | Expr>): PropertyRef {

src/utils/escape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function escapeString(str: string): string {
6666
}
6767

6868
function normalizeString(str: string): string {
69-
return str.replace(/\\u0060/g, "`");
69+
return str.replaceAll(/\\u0060/g, "`");
7070
}
7171

7272
function needsEscape(str: string): boolean {

src/utils/pad-block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
export function padBlock(block: string, spaces = 4): string {
2121
const paddingStr = " ".repeat(spaces);
22-
const paddedNewLines = block.replace(/\n/g, `\n${paddingStr}`);
22+
const paddedNewLines = block.replaceAll(/\n/g, `\n${paddingStr}`);
2323
return `${paddingStr}${paddedNewLines}`;
2424
}

0 commit comments

Comments
 (0)