@stoplight/yaml
Advanced tools
Comparing version
@@ -12,4 +12,9 @@ "use strict"; | ||
function getStartPosition(node) { | ||
if (node.parent && node.parent.kind === yaml_ast_parser_1.Kind.MAPPING && node.kind !== yaml_ast_parser_1.Kind.SCALAR) { | ||
return node.parent.key.endPosition + 1; | ||
if (node.parent && node.parent.kind === yaml_ast_parser_1.Kind.MAPPING) { | ||
if (node.parent.value === null) { | ||
return node.parent.endPosition; | ||
} | ||
if (node.kind !== yaml_ast_parser_1.Kind.SCALAR) { | ||
return node.parent.key.endPosition + 1; | ||
} | ||
} | ||
@@ -36,2 +41,7 @@ return node.startPosition; | ||
break; | ||
case yaml_ast_parser_1.Kind.SCALAR: | ||
if (node.parent.kind === yaml_ast_parser_1.Kind.MAPPING && node.parent.value === null) { | ||
return node.parent.endPosition; | ||
} | ||
break; | ||
} | ||
@@ -46,3 +56,8 @@ return node.endPosition; | ||
if (item.key.value === segment) { | ||
node = item.value; | ||
if (item.value === null) { | ||
node = item.key; | ||
} | ||
else { | ||
node = item.value; | ||
} | ||
continue pathLoop; | ||
@@ -49,0 +64,0 @@ } |
@@ -5,1 +5,2 @@ export * from './getJsonPathForPosition'; | ||
export * from './safeStringify'; | ||
export * from './types'; |
{ | ||
"name": "@stoplight/yaml", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Useful functions when working with YAML.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,3 +0,2 @@ | ||
import { IParserResult } from '@stoplight/types'; | ||
import { YAMLNode } from 'yaml-ast-parser'; | ||
export declare const parseWithPointers: <T>(value: string) => IParserResult<T, YAMLNode, number[]>; | ||
export declare const parseWithPointers: <T>(value: string) => import("@stoplight/types").IParserResult<T, YAMLNode, number[]>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42197
3.21%24
14.29%416
5.05%