Skip to content
EliteChart

memoizeSingle

Documentation


Documentation / @elitechart/core / memoizeSingle

code
function memoizeSingle<A, R>(compute): (arg) => R;

Defined in: util/memoize.ts:29

Wrap compute so that repeated calls with the same first argument (identity-compared, not value-compared) return the cached result. Any subsequent argument is ignored by the cache — the caller should use memoizeByKey when other args matter.

Type Parameters

A

A

R

R

Parameters

compute

(arg) => R

Returns

(arg) => R

Example

code
const fastSma = memoizeSingle((bars: Bar[]) => sma(bars, { period: 20 }));
  // Inside overlay:
  const values = fastSma(bars);