Skip to content

Commit

Permalink
Fix lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Mar 11, 2024
1 parent 0e580b9 commit cb4af99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/path/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,19 @@ export class InfixExpression extends FilterExpression {

public evaluate(context: FilterContext): boolean {
let left = this.left.evaluate(context);
if (!this.logical && left instanceof JSONPathNodeList && left.nodes.length === 1)
if (
!this.logical &&
left instanceof JSONPathNodeList &&
left.nodes.length === 1
)
left = left.nodes[0].value;

let right = this.right.evaluate(context);
if (!this.logical && right instanceof JSONPathNodeList && right.nodes.length === 1)
if (
!this.logical &&
right instanceof JSONPathNodeList &&
right.nodes.length === 1
)
right = right.nodes[0].value;

if (this.operator === "&&") {
Expand Down
13 changes: 6 additions & 7 deletions tests/path/query.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { query } from "../../src/path";

describe("JSONPath query", () => {
test("logical expression, existence tests", () => {
const path = "$[[email protected] && @.b]";
const data = [{"a": false, "b": false}];
expect(query(path, data).values()).toStrictEqual([{"a": false, "b": false}]);
});
}
);
test("logical expression, existence tests", () => {
const path = "$[[email protected] && @.b]";
const data = [{ a: false, b: false }];
expect(query(path, data).values()).toStrictEqual([{ a: false, b: false }]);
});
});

0 comments on commit cb4af99

Please sign in to comment.