@phenomnomnominal/tsquery
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -5,2 +5,3 @@ "use strict"; | ||
const traverse_1 = require("../traverse"); | ||
const sibling_1 = require("./sibling"); | ||
function nthChild(node, selector, ancestors) { | ||
@@ -26,5 +27,12 @@ const { right } = selector; | ||
} | ||
const children = node.parent.getChildren(); | ||
return children.indexOf(node) === getIndex(children.length); | ||
const keys = (0, sibling_1.getVisitorKeys)(node.parent || null); | ||
return keys.some((key) => { | ||
const prop = node.parent[key]; | ||
if (Array.isArray(prop)) { | ||
const index = prop.indexOf(node); | ||
return index >= 0 && index === getIndex(prop.length); | ||
} | ||
return false; | ||
}); | ||
} | ||
//# sourceMappingURL=nth-child.js.map |
@@ -5,1 +5,2 @@ import type { Adjacent, Sibling } from 'esquery'; | ||
export declare function adjacent(node: Node, selector: Adjacent, ancestors: Array<Node>): boolean; | ||
export declare function getVisitorKeys(node: Node | null): Array<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.adjacent = exports.sibling = void 0; | ||
exports.getVisitorKeys = exports.adjacent = exports.sibling = void 0; | ||
const traverse_1 = require("../traverse"); | ||
@@ -67,2 +67,3 @@ function sibling(node, selector, ancestors) { | ||
} | ||
exports.getVisitorKeys = getVisitorKeys; | ||
//# sourceMappingURL=sibling.js.map |
{ | ||
"name": "@phenomnomnominal/tsquery", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"description": "Query TypeScript ASTs with the esquery API!", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84556
1142