Constructor
new AsyncSearch(startopt, spaceopt, queueopt, maxopt, coresopt)
Create a new AsyncSearch instance.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
start |
Iterable | AsyncIterable | Promise.<Iterable> |
<optional> |
Initial candidates. |
|
space |
function |
<optional> |
Expansion function. |
|
queue |
Object |
<optional> |
Queue instance controlling iteration order. |
|
max |
number |
<optional> |
Maximum queue size. |
|
cores |
number |
<optional> |
16 | Number of concurrent expansions per batch. |
Classes
Members
cores :number
Number of concurrent expansions per batch.
Type:
- number
max :number|undefined
Maximum queue size (limits branching).
Type:
- number | undefined
queue :Object
Queue controlling search order (BFS, DFS, priority, etc.).
Must implement .addAll(), .poll(), .clear(), .n(), and optionally .select().
Type:
- Object
space :function|undefined
Expansion function describing the search space. Should return an async iterable, iterable, or promise resolving to an iterable.
Type:
- function | undefined
start :Iterable|AsyncIterable|Promise.<Iterable>|undefined
Initial candidates to seed the search.
Can be an array, an async iterable, a promise, or an AsyncEach instance.
Type:
- Iterable | AsyncIterable | Promise.<Iterable> | undefined
Methods
(async, generator) batchIterator() → {Array.<any>}
Lazily iterate over candidates asynchronously in batches. Each batch contains up to cores candidates.
Throws:
-
If the expansion function fails or returns invalid data.
- Type
- Error
Yields:
- Type
- Array.<any>
from(…starts) → {AsyncSearch}
Define the starting candidates for the search.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
starts |
* |
<repeatable> |
One or more initial candidates. |
Returns:
The current search instance (for chaining).
- Type
- AsyncSearch
inParallel(cores) → {AsyncSearch}
Define the concurrency level (number of candidates processed in parallel).
Parameters:
| Name | Type | Description |
|---|---|---|
cores |
number | Number of concurrent expansions. |
Returns:
The current search instance (for chaining).
- Type
- AsyncSearch
through(space) → {AsyncSearch}
Define the asynchronous expansion logic (search space).
Parameters:
| Name | Type | Description |
|---|---|---|
space |
function | Function describing the search space. |
Returns:
The current search instance (for chaining).
- Type
- AsyncSearch
via(queue, maxopt) → {AsyncSearch}
Define the queue strategy and optionally set a new maximum size.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
queue |
Object | Queue implementation controlling exploration order. |
|
max |
number |
<optional> |
Optional new maximum queue size. |
Returns:
The current search instance (for chaining).
- Type
- AsyncSearch