sample-api
Source: index.js:11
A small, fully-documented sample module that exists purely to demonstrate what an API reference page looks like when generated by clean-jsdoc-theme. It is not a real library — it is a showcase of the common JSDoc constructs (classes, methods, params, returns, examples, typedefs, and cross-references) and how the theme renders them.
Static Methods
createCache(entries, options) -> Cache
Create a Cache pre-populated from an object of key/value pairs.
Parameters
entries(Object.<string, *>) — Initial entries to seed the cache with.options(CacheOptions, optional) — Options forwarded to the Cache constructor.
Returns
Cache— A new, seeded cache.
Example
const cache = createCache({ a: 1, b: 2 }, { maxSize: 10 });
cache.get('b'); // => 2Other
CacheOptions
Options accepted by the Cache constructor.
Properties
maxSize(number, optional, default: 100) — Maximum number of entries to keep before the least-recently-used entry is evicted.ttl(number, optional, default: 0) — Time-to-live for an entry in milliseconds.0disables expiry.
Type
Object
Cache
A tiny in-memory, least-recently-used (LRU) cache.
This class is a demo of how clean-jsdoc-theme renders a documented class: the signature, the constructor, properties, and each method get their own section with parameters, return types, and examples.
Parameters
options(CacheOptions, optional, default: "{}") — Configuration for the cache.
Example
Basic usage
const cache = new Cache({ maxSize: 2 });
cache.set('a', 1);
cache.set('b', 2);
cache.get('a'); // => 1- See: