UNPKG

ts-japi

Version:

A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification

31 lines 1.38 kB
import { CacheOptions } from '../interfaces/cache.interface'; import { DataDocument } from '../interfaces/json-api.interface'; import { SerializerOptions } from '../interfaces/serializer.interface'; import { Dictionary, nullish, SingleOrArray } from '../types/global.types'; export default class Cache<PrimaryType extends Dictionary<any>> { /** * The default max for document storage */ static defaultLimit: number; /** @internal The storage for the cache */ private storage; /** * The maximum amount of documents that can be storage before erasure. */ private limit; /** * The method to use in determining data equality */ private resolver; /** * Creates a {@link Cache} * * @param limit - The maximum amount of documents that can be stored before erasure. */ constructor(options?: Partial<CacheOptions<PrimaryType>>); /** @internal Gets a document in the cache */ get(data: SingleOrArray<PrimaryType> | nullish, options?: Partial<SerializerOptions<PrimaryType>>): false | Partial<DataDocument<PrimaryType>>; /** @internal Sets a document in the cache */ set(data: SingleOrArray<PrimaryType> | nullish, document: Partial<DataDocument<PrimaryType>>, options?: Partial<SerializerOptions<PrimaryType>>): Partial<DataDocument<PrimaryType>>; } //# sourceMappingURL=cache.d.ts.map