Skip to content

Commit f8755b6

Browse files
committed
feat(core): add forefront option to enqueueLinks helper
Closes #1595
1 parent 3e90d37 commit f8755b6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/core/src/enqueue_links/enqueue_links.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
createRequestOptions,
1313
createRequests,
1414
} from './shared';
15-
import type { RequestQueue } from '../storages/request_queue';
15+
import type { RequestQueue, RequestQueueOperationOptions } from '../storages/request_queue';
1616
import type { RequestOptions } from '../request';
1717

18-
export interface EnqueueLinksOptions {
18+
export interface EnqueueLinksOptions extends RequestQueueOperationOptions {
1919
/** Limit the amount of actually enqueued URLs to this number. Useful for testing across the entire crawling scope. */
2020
limit?: number;
2121

@@ -169,6 +169,7 @@ export async function enqueueLinks(options: SetRequired<EnqueueLinksOptions, 're
169169
ow(options, ow.object.exactShape({
170170
urls: ow.array.ofType(ow.string),
171171
requestQueue: ow.object.hasKeys('fetchNextRequest', 'addRequest'),
172+
forefront: ow.optional.boolean,
172173
limit: ow.optional.number,
173174
selector: ow.optional.string,
174175
baseUrl: ow.optional.string,
@@ -202,6 +203,7 @@ export async function enqueueLinks(options: SetRequired<EnqueueLinksOptions, 're
202203
globs,
203204
regexps,
204205
transformRequestFunction,
206+
forefront,
205207
} = options;
206208

207209
const urlPatternObjects: UrlPatternObject[] = [];
@@ -281,7 +283,7 @@ export async function enqueueLinks(options: SetRequired<EnqueueLinksOptions, 're
281283
let requests = createFilteredRequests();
282284
if (limit) requests = requests.slice(0, limit);
283285

284-
return requestQueue.addRequests(requests);
286+
return requestQueue.addRequests(requests, { forefront });
285287
}
286288

287289
/**

0 commit comments

Comments
 (0)