Skip to content

Commit 0ab231b

Browse files
committed
fix: nodejs v20
1 parent 7fc393a commit 0ab231b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

packages/typescript-koa-runtime/src/query-parser.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import {
77
type Style,
88
} from "./query-parser"
99

10+
// todo: nodejs v20 doesn't support Iterator.from - replace when v20 support dropped.
11+
function* toIterator<T>(arr: T[]): IterableIterator<T> {
12+
yield* arr
13+
}
14+
1015
describe("query-parser", () => {
1116
describe("#parseCsvPairsToObject", () => {
1217
it("parses a single pair", () => {
@@ -27,7 +32,8 @@ describe("query-parser", () => {
2732
const expected = ["foo[0]", "foo[1]", "foo[2]"]
2833
const actual = extractArrayNotationKeys(
2934
"foo",
30-
Iterator.from(["foo[0]", "foo[2]", "foo[1]"]),
35+
// biome-ignore lint/suspicious/noExplicitAny: node v20
36+
toIterator(["foo[0]", "foo[2]", "foo[1]"]) as any,
3137
)
3238

3339
expect(actual).toEqual(expected)
@@ -37,7 +43,8 @@ describe("query-parser", () => {
3743
const expected = ["foo[bar][0]", "foo[bar][1]", "foo[bar][2]"]
3844
const actual = extractArrayNotationKeys(
3945
"foo[bar]",
40-
Iterator.from(["foo[bar][0]", "foo[bar][2]", "foo[bar][1]"]),
46+
// biome-ignore lint/suspicious/noExplicitAny: node v20
47+
toIterator(["foo[bar][0]", "foo[bar][2]", "foo[bar][1]"]) as any,
4148
)
4249

4350
expect(actual).toEqual(expected)
@@ -47,7 +54,8 @@ describe("query-parser", () => {
4754
const expected: string[] = []
4855
const actual = extractArrayNotationKeys(
4956
"foo",
50-
Iterator.from(["foo[bar]", "foo[baz]"]),
57+
// biome-ignore lint/suspicious/noExplicitAny: node v20
58+
toIterator(["foo[bar]", "foo[baz]"]) as any,
5159
)
5260

5361
expect(actual).toEqual(expected)

0 commit comments

Comments
 (0)