Skip to content

Conversation

Marcono1234
Copy link
Contributor

@Marcono1234 Marcono1234 commented Nov 7, 2021

Resolves #50

The implementation follows the behavior described in #50:

  • Only for onObjectBegin, onObjectProperty, onArrayBegin and onLiteralValue a JSON path supplier parameter was added
  • For onObjectProperty the path refers to the enclosing JSON object; including the current property name in the path already would be a bit inconsistent because it would not really be the path of the current property name
  • The path supplier function creates a copy of the internal path to avoid accidental modification

Additionally I have replaced assert.equal calls with assert.strictEqual and assert.deepEqual with assert.deepStrictEqual because these functions are marked as deprecated.

I am not that familiar with TypeScript, so any feedback is appreciated!

@Marcono1234 Marcono1234 marked this pull request as draft November 7, 2021 18:05

function assertNodeAtLocation(input: Node | undefined, segments: Segment[], expected: any) {
let actual = input && findNodeAtLocation(input, segments);
assert.deepEqual(actual ? getNodeValue(actual) : void 0, expected);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not replaced this with assert.deepStrictEqual because then the test fails.

@Marcono1234 Marcono1234 marked this pull request as ready for review November 7, 2021 18:30
@aeschli aeschli merged commit 35d94cd into microsoft:main Dec 30, 2021
@aeschli
Copy link
Contributor

aeschli commented Dec 30, 2021

Really cool, thanks @Marcono1234 !

@aeschli aeschli added this to the January 2022 milestone Dec 30, 2021
@Marcono1234 Marcono1234 deleted the marcono1234/visitor-json-path branch December 30, 2021 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants