@yuku-parser/wasm 0.5.27 → 0.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decode.js +12 -0
- package/index.d.ts +9 -0
- package/package.json +1 -1
- package/yuku-parser.wasm +0 -0
package/decode.js
CHANGED
|
@@ -688,6 +688,18 @@ function decode(buffer, source) {
|
|
|
688
688
|
}
|
|
689
689
|
return { line: lo, column: offset - ls[lo - 1] };
|
|
690
690
|
},
|
|
691
|
+
locNear(offset, hintLine) {
|
|
692
|
+
const ls = _getLineStarts();
|
|
693
|
+
let i = hintLine - 1;
|
|
694
|
+
if (i < 0) i = 0;
|
|
695
|
+
if (i >= ls.length) i = ls.length - 1;
|
|
696
|
+
if (ls[i] <= offset) {
|
|
697
|
+
while (i + 1 < ls.length && ls[i + 1] <= offset) i++;
|
|
698
|
+
} else {
|
|
699
|
+
while (i > 0 && ls[i] > offset) i--;
|
|
700
|
+
}
|
|
701
|
+
return { line: i + 1, column: offset - ls[i] };
|
|
702
|
+
},
|
|
691
703
|
};
|
|
692
704
|
}
|
|
693
705
|
export { decode };
|
package/index.d.ts
CHANGED
|
@@ -149,6 +149,15 @@ interface ParseResult {
|
|
|
149
149
|
* 1-based, columns are 0-based, matching ESTree's `loc` convention.
|
|
150
150
|
*/
|
|
151
151
|
locOf(offset: number): SourceLocation;
|
|
152
|
+
/**
|
|
153
|
+
* Resolves an offset to a `{ line, column }` pair, starting the search at
|
|
154
|
+
* `hintLine` and scanning toward the target line. For offsets resolved in
|
|
155
|
+
* roughly source order, pass the previously returned `line` as `hintLine`
|
|
156
|
+
* to keep lookups near-constant time, avoiding the binary search in
|
|
157
|
+
* {@link locOf}. `hintLine` is 1-based, like the returned `line`. Lines are
|
|
158
|
+
* 1-based, columns are 0-based, matching ESTree's `loc` convention.
|
|
159
|
+
*/
|
|
160
|
+
locNear(offset: number, hintLine: number): SourceLocation;
|
|
152
161
|
}
|
|
153
162
|
|
|
154
163
|
/**
|
package/package.json
CHANGED
package/yuku-parser.wasm
CHANGED
|
Binary file
|