Skip to content

Commit 85c67a6

Browse files
authored
Merge pull request #12 from chrismwendt/do-not-mutate
Do not mutate the given path
2 parents 5d3db88 + 80e0c7e commit 85c67a6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/impl/edit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export function removeProperty(text: string, path: JSONPath, formattingOptions:
1212
return setProperty(text, path, void 0, formattingOptions);
1313
}
1414

15-
export function setProperty(text: string, path: JSONPath, value: any, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] {
15+
export function setProperty(text: string, originalPath: JSONPath, value: any, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] {
16+
let path = originalPath.slice()
1617
let errors: ParseError[] = [];
1718
let root = parseTree(text, errors);
1819
let parent: Node | undefined = void 0;
@@ -160,4 +161,4 @@ export function applyEdit(text: string, edit: Edit): string {
160161

161162
export function isWS(text: string, offset: number) {
162163
return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
163-
}
164+
}

0 commit comments

Comments
 (0)