@stoplight/yaml
Advanced tools
Comparing version
@@ -5,5 +5,5 @@ "use strict"; | ||
const lineForPosition_1 = require("./lineForPosition"); | ||
exports.getLocationForJsonPath = ({ ast, lineMap }, path) => { | ||
const node = findNodeAtPath(ast, path); | ||
if (node === undefined) | ||
exports.getLocationForJsonPath = ({ ast, lineMap }, path, closest = false) => { | ||
const node = findNodeAtPath(ast, path, closest); | ||
if (node === void 0) | ||
return; | ||
@@ -49,3 +49,3 @@ return getLoc(lineMap, { start: getStartPosition(node), end: getEndPosition(node) }); | ||
} | ||
function findNodeAtPath(node, path) { | ||
function findNodeAtPath(node, path, closest) { | ||
pathLoop: for (const segment of path) { | ||
@@ -65,3 +65,3 @@ switch (node && node.kind) { | ||
} | ||
break; | ||
return closest ? node : void 0; | ||
case yaml_ast_parser_1.Kind.SEQ: | ||
@@ -74,3 +74,5 @@ for (let i = 0; i < node.items.length; i++) { | ||
} | ||
break; | ||
return closest ? node : void 0; | ||
default: | ||
return closest ? node : void 0; | ||
} | ||
@@ -77,0 +79,0 @@ } |
{ | ||
"name": "@stoplight/yaml", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Useful functions when working with YAML.", | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@stoplight/types": "4.x.x", | ||
"@stoplight/types": "5.x.x", | ||
"lodash": "4.x.x", | ||
@@ -30,0 +30,0 @@ "yaml-ast-parser": "0.0.43" |
@@ -37,3 +37,3 @@ "use strict"; | ||
case yaml_ast_parser_1.Kind.ANCHOR_REF: | ||
if (node.value !== undefined && isCircularAnchorRef(node)) { | ||
if (node.value !== void 0 && isCircularAnchorRef(node)) { | ||
node.value = dereferenceAnchor(node.value, node.referencesAnchor); | ||
@@ -40,0 +40,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42581
0.91%418
0.48%+ Added
- Removed
Updated