chore: bump version to 0.1477

Location: Ko Samui

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-02-04 07:24:32 +01:00
co-authored by Claude Opus 4.5
parent 99fa04df29
commit 8f0bbf33d6
27 changed files with 1098 additions and 448 deletions
+1
View File
@@ -33,3 +33,4 @@ export {
fuzzyPhraseMatch,
todoContentHash,
} from './string-similarity.js';
export { assertNever } from './type-safety.js';
+13
View File
@@ -199,10 +199,15 @@ export class LRUMap<K, V> extends Map<K, V> {
const now = Date.now();
const cutoff = now - maxAge;
let evicted = 0;
let deletedNewest = false;
// Iterate from oldest to newest
for (const [key, value] of super.entries()) {
if (getTimestamp(value) < cutoff) {
// Track if we're deleting the newest key
if (key === this._newestKey) {
deletedNewest = true;
}
super.delete(key);
this.onEvict?.(key, value);
evicted++;
@@ -213,6 +218,14 @@ export class LRUMap<K, V> extends Map<K, V> {
}
}
// Update _newestKey if we deleted it (find new newest from remaining entries)
if (deletedNewest) {
this._newestKey = undefined;
for (const k of super.keys()) {
this._newestKey = k; // Last one becomes newest
}
}
return evicted;
}
+35
View File
@@ -0,0 +1,35 @@
/**
* @fileoverview Type safety utilities for exhaustive checking.
*
* @module utils/type-safety
*/
/**
* Assert that a value should never occur at runtime.
* Used in switch/case default blocks to ensure exhaustive handling.
*
* If TypeScript sees a code path where `value` is not `never`,
* it will report a compile-time error, catching missing cases.
*
* @param value - The value that should be of type `never`
* @param message - Optional custom error message
* @throws Error if called at runtime (indicates unhandled case)
*
* @example
* type Status = 'active' | 'inactive' | 'pending';
* function handleStatus(status: Status): void {
* switch (status) {
* case 'active': // handle active
* break;
* case 'inactive': // handle inactive
* break;
* case 'pending': // handle pending
* break;
* default:
* assertNever(status); // Compile error if case is missing
* }
* }
*/
export function assertNever(value: never, message?: string): never {
throw new Error(message ?? `Unexpected value: ${JSON.stringify(value)}`);
}