mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
35 lines
878 B
TypeScript
35 lines
878 B
TypeScript
// Type definitions for lru-cache v2.5.0
|
|
// Project: https://github.com/isaacs/node-lru-cache
|
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
declare module 'lru-cache' {
|
|
function LRU<T>(opts: LRU.Options<T>): LRU.Cache<T>;
|
|
function LRU<T>(max: number): LRU.Cache<T>;
|
|
|
|
namespace LRU {
|
|
interface Options<T> {
|
|
max?: number;
|
|
maxAge?: number;
|
|
length?: (value: T) => number;
|
|
dispose?: (key: string, value: T) => void;
|
|
stale?: boolean;
|
|
}
|
|
|
|
interface Cache<T> {
|
|
set(key: string, value: T): void;
|
|
get(key: string): T;
|
|
peek(key: string): T;
|
|
has(key: string): boolean
|
|
del(key: string): void;
|
|
reset(): void;
|
|
forEach(iter: (value: T, key: string, cache: Cache<T>) => void, thisp?: any): void;
|
|
|
|
keys(): string[];
|
|
values(): T[];
|
|
}
|
|
}
|
|
|
|
export = LRU;
|
|
}
|