summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist/parse/line-counter.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/yaml/dist/parse/line-counter.js
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/yaml/dist/parse/line-counter.js')
-rw-r--r--node_modules/yaml/dist/parse/line-counter.js41
1 files changed, 0 insertions, 41 deletions
diff --git a/node_modules/yaml/dist/parse/line-counter.js b/node_modules/yaml/dist/parse/line-counter.js
deleted file mode 100644
index 0e7383bd..00000000
--- a/node_modules/yaml/dist/parse/line-counter.js
+++ /dev/null
@@ -1,41 +0,0 @@
-'use strict';
-
-/**
- * Tracks newlines during parsing in order to provide an efficient API for
- * determining the one-indexed `{ line, col }` position for any offset
- * within the input.
- */
-class LineCounter {
- constructor() {
- this.lineStarts = [];
- /**
- * Should be called in ascending order. Otherwise, call
- * `lineCounter.lineStarts.sort()` before calling `linePos()`.
- */
- this.addNewLine = (offset) => this.lineStarts.push(offset);
- /**
- * Performs a binary search and returns the 1-indexed { line, col }
- * position of `offset`. If `line === 0`, `addNewLine` has never been
- * called or `offset` is before the first known newline.
- */
- this.linePos = (offset) => {
- let low = 0;
- let high = this.lineStarts.length;
- while (low < high) {
- const mid = (low + high) >> 1; // Math.floor((low + high) / 2)
- if (this.lineStarts[mid] < offset)
- low = mid + 1;
- else
- high = mid;
- }
- if (this.lineStarts[low] === offset)
- return { line: low + 1, col: 1 };
- if (low === 0)
- return { line: 0, col: offset };
- const start = this.lineStarts[low - 1];
- return { line: low, col: offset - start + 1 };
- };
- }
-}
-
-exports.LineCounter = LineCounter;