UNPKG

r3bl-ts-utils

Version:

The `r3bl-ts-utils` package is a set of useful TypeScript functions and classes that can be used in Node.js and browser environments. They are inspired by Kotlin stdlib, and Rust to write code as expressions rather than statements, colorized text, powerfu

32 lines (31 loc) 1.56 kB
export * from "./externals"; import { Cache, EvictionPolicy } from "./externals"; /** * cache-utils is a module that exposes very little to the users of this module by defining a clear * boundary between external and internal facing code. * * The trick that `index.ts` inside the timer-utils folder only exposes symbols that are defined * in `externals.ts`. The factory function `createCache()` eliminates the need to access the * internal implementation `CacheImpl` class by any external code. * * On the other side (code using this library) the folder itself is imported, not a specific * file, using `import * as timer from "./cache-utils"`. Here, `cache-utils` is a folder, * and not a file. * * Internal * -------- * For code inside this module, everything is openly exposed and is considered internal. Inside the * module, there are no protections in place. All symbols are internal except the ones that are * exposed via `externals.ts` and the `index.ts` file. * * External * -------- * For users of this module, who don't care about the internal details of this module (and they * shouldn't have to), the main file is `externals.ts`. This following symbols are * exported by `index.ts`. * * 0. index.ts <- Re-export all the external symbols (and factory function) * 1. externals.ts <- External interfaces, types */ /** Factory function to create an object that implements (external) Cache interface. */ export declare const createCache: <K, V>(name: string, maxSize: number, policy: EvictionPolicy) => Cache<K, V>;