SortedValue interface
Represents a value with its original position that can be used in search operations.
Example
// Example of SortedValue objects created from a choices array
const choices = ["red", "green", "blue"];
const sortedValues: SortedValue[] = choices.map((value, index) => ({
value,
index
}));
// Results in:
// [
// { value: "red", index: 0 },
// { value: "green", index: 1 },
// { value: "blue", index: 2 }
// ]
Remarks
This interface is used internally by the search algorithm to maintain the relationship between search values and their original positions in the source array.
Properties
| index | The zero-based index position of this value in the original source array. Example
|
| value | The string value to be searched for during matching operations. Example
|
Property Details
index
The zero-based index position of this value in the original source array.
Example
0 for the first item, 1 for the second item, etc.
index: number
Property Value
number
Remarks
This allows the search algorithm to correlate found matches back to their original positions, which is essential for maintaining proper choice selection.
value
The string value to be searched for during matching operations.
Example
"red", "green", "blue" when searching color choices
value: string
Property Value
string
Remarks
This is the actual text content that will be compared against user input.