MCPcopy
hub / github.com/docsifyjs/docsify / cached

Function cached

src/core/util/core.js:7–14  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

5 */
6
7export function cached(fn) {
8 const cache = Object.create(null);
9 return function (str) {
10 const key = isPrimitive(str) ? str : JSON.stringify(str);
11 const hit = cache[key];
12 return hit || (cache[key] = fn(str));
13 };
14}
15
16/**
17 * Hyphenate a camelCase string.

Callers 3

constructorMethod · 0.90
util.jsFile · 0.90
core.jsFile · 0.85

Calls 1

isPrimitiveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…