Skip to content

Commit feed808

Browse files
authored
Merge pull request #49 from serpapi/deno
Fix Deno 2 lint and type compatibility
2 parents 9e409bd + 45e36bd commit feed808

9 files changed

Lines changed: 22 additions & 33 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
`serpapi-javascript` is developed using Deno. Refer to
66
https://deno.land/manual/getting_started/installation to install Deno.
77

8-
Ensure you're running at least Deno v1.28.3.
8+
Ensure you're running at least Deno v1.46.3.
99

1010
```bash
1111
deno --version

‎deno.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
"test:cov": "rm -rf cov_profile && deno task test --coverage=cov_profile && deno coverage cov_profile",
77
"npm": "deno run -A scripts/build_npm.ts"
88
},
9+
"imports": {
10+
"@deno/dnt": "https://deno.land/x/dnt@0.40.0/mod.ts",
11+
"@std/dotenv": "https://deno.land/std@0.173.0/dotenv/mod.ts",
12+
"@std/testing/asserts": "https://deno.land/std@0.170.0/testing/asserts.ts",
13+
"@std/testing/bdd": "https://deno.land/std@0.170.0/testing/bdd.ts",
14+
"@std/testing/mock": "https://deno.land/std@0.170.0/testing/mock.ts"
15+
},
916
"fmt": {
1017
"exclude": ["npm/", "examples/node", "smoke_tests/"]
1118
},

‎examples/deno/basic_example.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loadSync } from "https://deno.land/std@0.173.0/dotenv/mod.ts";
1+
import { loadSync } from "@std/dotenv";
22
import { config, getJson } from "../../mod.ts";
33

44
const { API_KEY: apiKey } = loadSync();

‎examples/deno/pagination_example.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loadSync } from "https://deno.land/std@0.173.0/dotenv/mod.ts";
1+
import { loadSync } from "@std/dotenv";
22
import { config, getJson } from "../../mod.ts";
33

44
const { API_KEY: apiKey } = loadSync();

‎scripts/build_npm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts";
1+
import { build, emptyDir } from "@deno/dnt";
22
import { version } from "../version.ts";
33

44
await emptyDir("./npm");

‎src/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function execute(
8080
});
8181

8282
return new Promise((resolve, reject) => {
83-
let timer: number;
83+
let timer: ReturnType<typeof setTimeout>;
8484

8585
const handleResponse = (resp: http.IncomingMessage) => {
8686
resp.setEncoding("utf8");

‎tests/serpapi_test.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import { loadSync } from "https://deno.land/std@0.170.0/dotenv/mod.ts";
2-
import {
3-
afterAll,
4-
afterEach,
5-
beforeAll,
6-
describe,
7-
it,
8-
} from "https://deno.land/std@0.170.0/testing/bdd.ts";
1+
import { loadSync } from "@std/dotenv";
2+
import { afterAll, afterEach, beforeAll, describe, it } from "@std/testing/bdd";
93
import {
104
assert,
115
assertArrayIncludes,
@@ -14,14 +8,14 @@ import {
148
assertInstanceOf,
159
assertRejects,
1610
assertStringIncludes,
17-
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
11+
} from "@std/testing/asserts";
1812
import {
1913
assertSpyCallArg,
2014
assertSpyCalls,
2115
spy,
2216
Stub,
2317
stub,
24-
} from "https://deno.land/std@0.170.0/testing/mock.ts";
18+
} from "@std/testing/mock";
2519
import { _internals } from "../src/utils.ts";
2620
import {
2721
BaseResponse,

‎tests/utils_test.ts‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import http from "node:http";
22
import qs from "node:querystring";
3-
import { loadSync } from "https://deno.land/std@0.170.0/dotenv/mod.ts";
4-
import {
5-
afterAll,
6-
beforeAll,
7-
describe,
8-
it,
9-
} from "https://deno.land/std@0.170.0/testing/bdd.ts";
10-
import { Stub, stub } from "https://deno.land/std@0.170.0/testing/mock.ts";
3+
import { loadSync } from "@std/dotenv";
4+
import { afterAll, beforeAll, describe, it } from "@std/testing/bdd";
5+
import { Stub, stub } from "@std/testing/mock";
116
import {
127
assertEquals,
138
assertInstanceOf,
149
assertMatch,
15-
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
10+
} from "@std/testing/asserts";
1611
import {
1712
_internals,
1813
buildRequestOptions,

‎tests/validators_test.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import {
2-
afterEach,
3-
describe,
4-
it,
5-
} from "https://deno.land/std@0.170.0/testing/bdd.ts";
6-
import {
7-
assertEquals,
8-
assertThrows,
9-
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
1+
import { afterEach, describe, it } from "@std/testing/bdd";
2+
import { assertEquals, assertThrows } from "@std/testing/asserts";
103
import { validateApiKey, validateTimeout } from "../src/validators.ts";
114
import { config, InvalidTimeoutError, MissingApiKeyError } from "../mod.ts";
125

0 commit comments

Comments
 (0)