UNPKG

@httpc/kit

Version:

httpc toolbox for building function-based API with minimal code and end-to-end type safety

44 lines (43 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaterfallCache = void 0; class WaterfallCache { constructor(options) { this.providers = options.providers; } keys() { return this.providers[0].keys(); } has(key) { for (const p of this.providers) { if (p.has(key)) { return true; } } return false; } get(key) { for (const p of this.providers) { const value = p.get(key); if (value !== null && value !== undefined) { return value; } } } set(key, value) { for (const p of this.providers) { p.set(key, value); } } delete(key) { for (const p of this.providers) { p.delete(key); } } clear() { for (const p of this.providers) { p.clear(); } } } exports.WaterfallCache = WaterfallCache;