Skip to content

Commit e5fd906

Browse files
committed
fix: add await before nextNonEof
1 parent c7bc455 commit e5fd906

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ class JsonParser<T> {
7575
}
7676

7777
async #skipWhiteSpaces() {
78-
for (
79-
let char = await this.#peekNonEof(1, 'skipWhiteSpaces');
80-
this.#isWhitespace(char);
81-
char = await this.#peekNonEof(1, 'skipWhiteSpaces')
78+
while (
79+
this.#isWhitespace(await this.#peekNonEof())
8280
) {
83-
this.#nextNonEof();
81+
await this.#nextNonEof();
8482
}
8583
}
8684

@@ -132,6 +130,7 @@ class JsonParser<T> {
132130
if (skip) await this.#skipWhiteSpaces();
133131
const next = await this.#peekNonEof();
134132

133+
console.log(next);
135134
switch (next) {
136135
case '{':
137136
return this.parseObject();

test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const testCases = [
1919
},
2020
{
2121
name: 'Object with array',
22-
input: '{numbers:[1,2,3],active:true}',
23-
expected: { numbers: [1, 2, 3], active: true }
22+
input: '{title:[1,2,3],active:[{title: "test"}]}',
23+
expected: { title: [1, 2, 3], active: [{ title: 'test' }] }
2424
},
2525
{
2626
name: 'Array of objects',

0 commit comments

Comments
 (0)