@@ -27,24 +27,23 @@ const SEARCH_ARCHIVE_PATH = `/searches`;
2727 * - Accepts an optional callback.
2828 * - Get the next page of results by calling the `.next()` method on the returned response object.
2929 *
30- * @param {string } engine - engine name
3130 * @param {object } parameters - search query parameters for the engine
3231 * @param {fn= } callback - optional callback
3332 * @example
3433 * // single call (async/await)
35- * const json = await getJson("google", { api_key: API_KEY, q: "coffee" });
34+ * const json = await getJson({ engine: "google", api_key: API_KEY, q: "coffee" });
3635 *
3736 * // single call (callback)
38- * getJson("google", { api_key: API_KEY, q: "coffee" }, console.log);
37+ * getJson({ engine: "google", api_key: API_KEY, q: "coffee" }, console.log);
3938 *
4039 * @example
4140 * // pagination (async/await)
42- * const page1 = await getJson("google", { q: "coffee", start: 15 });
41+ * const page1 = await getJson({ engine: "google", q: "coffee", start: 15 });
4342 * const page2 = await page1.next?.();
4443 *
4544 * @example
4645 * // pagination (callback)
47- * getJson("google", { q: "coffee", start: 15 }, (page1) => {
46+ * getJson({ engine: "google", q: "coffee", start: 15 }, (page1) => {
4847 * page1.next?.((page2) => {
4948 * console.log(page2);
5049 * });
@@ -53,7 +52,7 @@ const SEARCH_ARCHIVE_PATH = `/searches`;
5352 * @example
5453 * // pagination loop (async/await)
5554 * const organicResults = [];
56- * let page = await getJson("google", { api_key: API_KEY, q: "coffee" });
55+ * let page = await getJson({ engine: "google", api_key: API_KEY, q: "coffee" });
5756 * while (page) {
5857 * organicResults.push(...page.organic_results);
5958 * if (organicResults.length >= 30) break;
@@ -63,7 +62,7 @@ const SEARCH_ARCHIVE_PATH = `/searches`;
6362 * @example
6463 * // pagination loop (callback)
6564 * const organicResults = [];
66- * getJson("google", { api_key: API_KEY, q: "coffee" }, (page) => {
65+ * getJson({ engine: "google", api_key: API_KEY, q: "coffee" }, (page) => {
6766 * organicResults.push(...page.organic_results);
6867 * if (organicResults.length < 30 && page.next) {
6968 * page.next();
@@ -114,15 +113,14 @@ export async function getJson<
114113 * - Accepts an optional callback.
115114 * - Responds with a JSON string if the search request hasn't completed.
116115 *
117- * @param {string } engine - engine name
118116 * @param {object } parameters - search query parameters for the engine
119117 * @param {fn= } callback - optional callback
120118 * @example
121119 * // async/await
122- * const html = await getHtml("google", { api_key: API_KEY, q: "coffee" });
120+ * const html = await getHtml({ engine: "google", api_key: API_KEY, q: "coffee" });
123121 *
124122 * // callback
125- * getHtml("google", { api_key: API_KEY, q: "coffee" }, console.log);
123+ * getHtml({ engine: "google", api_key: API_KEY, q: "coffee" }, console.log);
126124 */
127125export async function getHtml <
128126 E extends EngineName = EngineName ,
@@ -159,7 +157,7 @@ export async function getHtml<
159157 * @param {number= } [parameters.timeout] - timeout in milliseconds
160158 * @param {fn= } callback - optional callback
161159 * @example
162- * const response = await getJson("google", { api_key: API_KEY, async: true, q: "coffee" });
160+ * const response = await getJson({ engine: "google", api_key: API_KEY, async: true, q: "coffee" });
163161 * const { id } = response.search_metadata;
164162 * await delay(1000); // wait for the request to be processed.
165163 *
@@ -204,7 +202,7 @@ export async function getJsonBySearchId<
204202 * @param {number= } [parameters.timeout] - timeout in milliseconds
205203 * @param {fn= } callback - optional callback
206204 * @example
207- * const response = await getJson("google", { api_key: API_KEY, async: true, q: "coffee" });
205+ * const response = await getJson({ engine: "google", api_key: API_KEY, async: true, q: "coffee" });
208206 * const { id } = response.search_metadata;
209207 * await delay(1000); // wait for the request to be processed.
210208 *
0 commit comments