typing is now correct for the file system

This commit is contained in:
2025-03-06 17:29:30 -05:00
parent b7babb665e
commit b3fa561c76
4 changed files with 80 additions and 72 deletions

View File

@ -1,5 +1,4 @@
import { type Entry } from "./main"
import { type Files } from "./collection"
interface Wrap<T> {
readonly result: T,
@ -9,14 +8,14 @@ function wrap_result<T>(result: T, index: number): Wrap<T> {
return { result: result, index: index }
}
export default function entry_search<T extends Entry<T>>(cloned_file_collection: Files<T>, file_name: string): Wrap<Entry<T>> | undefined {
export default function entry_search<T extends Entry>(cloned_file_collection: T[], file_name: string): Wrap<T> | undefined {
let start = 0
let end = cloned_file_collection.length-1
while (start<=end) {
const median = (start+end)>>1
const median_name = cloned_file_collection[median].name
if (median_name == file_name) { //left == right && (T == U) is not necessary
if (median_name === file_name) {
return wrap_result(cloned_file_collection[median], median)
} else if (median_name<file_name) {
start = median+1