@types/stale-lru-cache
TypeScript icon, indicating that this package has built-in type declarations

5.1.6 • Public • Published

Installation

npm install --save @types/stale-lru-cache

Summary

This package contains type definitions for stale-lru-cache (https://github.com/cyberthom/stale-lru-cache).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/stale-lru-cache.

index.d.ts

declare class Cache<K, V> {
    constructor(options?: Cache.CacheOptions<K, V>);
    delete(key: K): boolean;
    get(key: K): V | undefined;
    set(key: K, value: V, options?: string | Cache.SetOptions<K, V>): boolean;
    has(key: K): boolean;
    isStale(key: K): boolean;
    keys(): K[];
    reset(): void;
    size(): number;
    values(): V[];
    wrap(
        key: K,
        revalidate: Cache.RevalidationCallback<K, V>,
        callback: Cache.OptionsCallback<K, V>,
    ): void;
}

declare namespace Cache {
    type OptionsCallback<K, V> = (error: any, value?: V, options?: string | SetOptions<K, V>) => void;
    type RevalidationCallback<K, V> = (key: K, callback: OptionsCallback<K, V>) => void;

    interface CacheOptions<K, V> {
        maxAge?: number | undefined;
        staleWhileRevalidate?: number | undefined;
        revalidate?: RevalidationCallback<K, V> | undefined;
        maxSize?: number | undefined;
        getSize?(value: V, key: K): number;
    }

    interface SetOptions<K, V> {
        maxAge?: number | undefined;
        staleWhileRevalidate?: number | undefined;
        revalidate?: RevalidationCallback<K, V> | undefined;
    }
}

export = Cache;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by Joona Heikkilä.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/stale-lru-cache

Weekly Downloads

2,268

Version

5.1.6

License

MIT

Unpacked Size

4.98 kB

Total Files

5

Last publish

Collaborators

  • types