@@ -51,41 +51,39 @@ class YAMLException extends Error {
5151 toString ( compact ?: boolean ) {
5252 return `${ this . name } : ${ formatError ( this , compact ) } `
5353 }
54- }
5554
56- /**
57- * Build a YAMLException with a source snippet and throw it. `source` is the
58- * raw input text (no parser sentinel); `position` is an offset into it.
59- *
60- * @internal
61- */
62- function throwErrorAt ( source : string , position : number , message : string , filename = '' ) : never {
63- let line = 0
64- let lineStart = 0
65-
66- for ( let index = 0 ; index < position ; index ++ ) {
67- const ch = source . charCodeAt ( index )
68-
69- if ( ch === 0x0A /* LF */ ) {
70- line ++
71- lineStart = index + 1
72- } else if ( ch === 0x0D /* CR */ ) {
73- line ++
74- if ( source . charCodeAt ( index + 1 ) === 0x0A /* LF */ ) index ++
75- lineStart = index + 1
55+ /**
56+ * Builds a YAMLException with a source snippet and throws it. `source` is
57+ * the raw input text; `position` is an offset into it.
58+ */
59+ static throwAt ( source : string , position : number , message : string , filename = '' ) : never {
60+ let line = 0
61+ let lineStart = 0
62+
63+ for ( let index = 0 ; index < position ; index ++ ) {
64+ const ch = source . charCodeAt ( index )
65+
66+ if ( ch === 0x0A /* LF */ ) {
67+ line ++
68+ lineStart = index + 1
69+ } else if ( ch === 0x0D /* CR */ ) {
70+ line ++
71+ if ( source . charCodeAt ( index + 1 ) === 0x0A /* LF */ ) index ++
72+ lineStart = index + 1
73+ }
7674 }
77- }
7875
79- const mark : SnippetMark = {
80- name : filename ,
81- buffer : source ,
82- position,
83- line,
84- column : position - lineStart
85- }
76+ const mark : SnippetMark = {
77+ name : filename ,
78+ buffer : source ,
79+ position,
80+ line,
81+ column : position - lineStart
82+ }
8683
87- mark . snippet = makeSnippet ( mark )
88- throw new YAMLException ( message , mark )
84+ mark . snippet = makeSnippet ( mark )
85+ throw new YAMLException ( message , mark )
86+ }
8987}
9088
91- export { YAMLException , throwErrorAt }
89+ export { YAMLException }
0 commit comments