Skip to content

Commit

Permalink
Merge pull request #12 from chrismwendt/do-not-mutate
Browse files Browse the repository at this point in the history
Do not mutate the given path
  • Loading branch information
aeschli authored Aug 24, 2018
2 parents 5d3db88 + 80e0c7e commit 85c67a6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/impl/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function removeProperty(text: string, path: JSONPath, formattingOptions:
return setProperty(text, path, void 0, formattingOptions);
}

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

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

0 comments on commit 85c67a6

Please sign in to comment.