Skip to content

Commit e259f58

Browse files
committed
Rename 'LOOSE' mode to 'LAX' mode
1 parent 4694c52 commit e259f58

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

bench/decode.bench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const BENCHMARKS = await (async () => {
2525

2626
for (const { name, mapJson, size } of BENCHMARKS) {
2727
Deno.bench(`${name}, lax, ${format(size)}`, () => {
28-
decode(mapJson, { mode: DecodeMode.LOOSE });
28+
decode(mapJson, { mode: DecodeMode.LAX });
2929
});
3030

3131
Deno.bench(`${name}, strict, ${format(size)}`, () => {

src/decode/decode.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("decode", () => {
155155
encoder.addUnsignedVLQs(Tag.ORIGINAL_SCOPE_END, 0, 0).finishItem();
156156
const map = createMap(encoder.encode(), []);
157157

158-
const info = decode(map, { mode: DecodeMode.LOOSE });
158+
const info = decode(map, { mode: DecodeMode.LAX });
159159

160160
assertEquals(info.scopes, []);
161161
});
@@ -168,12 +168,12 @@ describe("decode", () => {
168168
assertThrows(() => decode(map, { mode: DecodeMode.STRICT }));
169169
});
170170

171-
it("ignores 'open' scopes left at the end in loose mode", () => {
171+
it("ignores 'open' scopes left at the end in lax mode", () => {
172172
const encoder = new ItemEncoder();
173173
encoder.addUnsignedVLQs(Tag.ORIGINAL_SCOPE_START, 0, 0, 0).finishItem();
174174
const map = createMap(encoder.encode(), []);
175175

176-
const info = decode(map, { mode: DecodeMode.LOOSE });
176+
const info = decode(map, { mode: DecodeMode.LAX });
177177

178178
assertEquals(info.scopes, []);
179179
});
@@ -187,18 +187,18 @@ describe("decode", () => {
187187
assertThrows(() => decode(map, { mode: DecodeMode.STRICT }));
188188
});
189189

190-
it("ignores GENERATED_RANGE_END items without START in loose mode", () => {
190+
it("ignores GENERATED_RANGE_END items without START in lax mode", () => {
191191
const encoder = new ItemEncoder();
192192
encoder.addUnsignedVLQs(Tag.GENERATED_RANGE_END);
193193
encoder.addSignedVLQs(42).finishItem();
194194
const map = createMap(encoder.encode(), []);
195195

196-
const info = decode(map, { mode: DecodeMode.LOOSE });
196+
const info = decode(map, { mode: DecodeMode.LAX });
197197

198198
assertEquals(info.ranges, []);
199199
});
200200

201-
it("throws for un-matched GENERATED_RANGE_START at the end in loose mode", () => {
201+
it("throws for un-matched GENERATED_RANGE_START at the end in lax mode", () => {
202202
const encoder = new ItemEncoder();
203203
encoder.addUnsignedVLQs(Tag.GENERATED_RANGE_START, 0);
204204
encoder.addSignedVLQs(42).finishItem();
@@ -207,13 +207,13 @@ describe("decode", () => {
207207
assertThrows(() => decode(map, { mode: DecodeMode.STRICT }));
208208
});
209209

210-
it("ignores un-matched GENERATED_RANGE_START at the end in loose mode", () => {
210+
it("ignores un-matched GENERATED_RANGE_START at the end in lax mode", () => {
211211
const encoder = new ItemEncoder();
212212
encoder.addUnsignedVLQs(Tag.GENERATED_RANGE_START, 0);
213213
encoder.addSignedVLQs(42).finishItem();
214214
const map = createMap(encoder.encode(), []);
215215

216-
const info = decode(map, { mode: DecodeMode.LOOSE });
216+
const info = decode(map, { mode: DecodeMode.LAX });
217217

218218
assertEquals(info.ranges, []);
219219
});
@@ -227,13 +227,13 @@ describe("decode", () => {
227227
assertThrows(() => decode(map, { mode: DecodeMode.STRICT }));
228228
});
229229

230-
it("ignores free ORIGINAL_SCOPE_VARIABLES items in loose mode", () => {
230+
it("ignores free ORIGINAL_SCOPE_VARIABLES items in lax mode", () => {
231231
const encoder = new ItemEncoder();
232232
encoder.addUnsignedVLQs(Tag.ORIGINAL_SCOPE_VARIABLES);
233233
encoder.addSignedVLQs(0, 1).finishItem();
234234
const map = createMap(encoder.encode(), ["foo", "bar"]);
235235

236-
const info = decode(map, { mode: DecodeMode.LOOSE });
236+
const info = decode(map, { mode: DecodeMode.LAX });
237237

238238
assertEquals(info.scopes, []);
239239
});
@@ -247,13 +247,13 @@ describe("decode", () => {
247247
assertThrows(() => decode(map, { mode: DecodeMode.STRICT }));
248248
});
249249

250-
it("ignores free ORIGINAL_SCOPE_VARIABLES items in loose mode", () => {
250+
it("ignores free ORIGINAL_SCOPE_VARIABLES items in lax mode", () => {
251251
const encoder = new ItemEncoder();
252252
encoder.addUnsignedVLQs(Tag.GENERATED_RANGE_BINDINGS);
253253
encoder.addSignedVLQs(0, -1).finishItem();
254254
const map = createMap(encoder.encode(), ["foo"]);
255255

256-
const info = decode(map, { mode: DecodeMode.LOOSE });
256+
const info = decode(map, { mode: DecodeMode.LAX });
257257

258258
assertEquals(info.scopes, []);
259259
});

src/decode/decode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { TokenIterator } from "../vlq.ts";
2020
/**
2121
* The mode decides how well-formed the encoded scopes have to be, to be accepted by the decoder.
2222
*
23-
* LOOSE is the default and is much more lenient. It's still best effort though and the decoder doesn't
23+
* LAX is the default and is much more lenient. It's still best effort though and the decoder doesn't
2424
* implement any error recovery: e.g. superfluous "start" items can lead to whole trees being omitted.
2525
*
2626
* STRICT mode will throw in the following situations:
@@ -33,7 +33,7 @@ import { TokenIterator } from "../vlq.ts";
3333
*/
3434
export const enum DecodeMode {
3535
STRICT = 1,
36-
LOOSE = 2,
36+
LAX = 2,
3737
}
3838

3939
export function decode(
@@ -80,7 +80,7 @@ class Decoder {
8080
constructor(scopes: string, names: string[], options?: { mode: DecodeMode }) {
8181
this.#encodedScopes = scopes;
8282
this.#names = names;
83-
this.#mode = options?.mode ?? DecodeMode.LOOSE;
83+
this.#mode = options?.mode ?? DecodeMode.LAX;
8484
}
8585

8686
decode(): ScopeInfo {

0 commit comments

Comments
 (0)