( state: FileState, files: ReadonlyArray<string>, figures: Effect.Success<typeof platformFigures>, options: FileOptionsReq, renderOptions?: RenderOptions | undefined )
| 2268 | }) |
| 2269 | |
| 2270 | const filterFiles = (files: ReadonlyArray<string>, query: string) => { |
| 2271 | if (query.length === 0) { |
| 2272 | return files |
| 2273 | } |
| 2274 | const normalizedQuery = query.toLowerCase() |
| 2275 | const filtered: Array<string> = [] |
| 2276 | for (let index = 0; index < files.length; index++) { |
| 2277 | if (files[index].toLowerCase().includes(normalizedQuery)) { |
| 2278 | filtered.push(files[index]) |
| 2279 | } |
| 2280 | } |
| 2281 | return filtered |
| 2282 | } |
| 2283 | |
| 2284 | const updateFileState = ( |
| 2285 | state: FileState, |
| 2286 | query: string, |
| 2287 | allFiles: ReadonlyArray<string> = state.allFiles |
| 2288 | ): FileState => { |
| 2289 | const files = filterFiles(allFiles, query) |
| 2290 | if (files.length === 0) { |
| 2291 | return { ...state, query, allFiles, files, cursor: 0 } |
| 2292 | } |
| 2293 | const selected = state.files[state.cursor] |
| 2294 | const cursor = selected === undefined ? 0 : files.indexOf(selected) |
| 2295 | return { |
no test coverage detected
searching dependent graphs…