Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 17 lines · 483 B · at 503e839

import { type Option, type Result } from "@tsus/runtime";export type LruError = { kind: "invalid_capacity" };export type Lru<V> = {  /** The stored value, or None when the key is missing. */  get: (key: string) => Option<V>;  set: (key: string, value: V) => void;  delete: (key: string) => boolean;  size: () => number;  /** Most recently used first. */  keys: () => string[];};export const createLru = <V>(capacity: number): Result<Lru<V>, LruError> => {  // TODO};