Skip to content

memoObject

The memoObject() function builds a proxy around a memoized object. The getter is evaluated lazily on first access, then all reads/writes target the same object.

Interactive example

Syntax

typescript
function memoObject<
	GenericOutput extends object
>(
	getter: () => GenericOutput
): GenericOutput;

Parameters

  • getter : Function called on first access to produce the proxied object.

Return value

A proxied GenericOutput object:

  • reads (obj.prop) return values from the memoized object;
  • writes (obj.prop = value) mutate the memoized object;
  • Object.keys() and the in operator reflect keys after writes.

See also

  • memo - Lazy memoization for synchronous values
  • memoPromise - Lazy memoization for async-capable values
  • override - Override methods and default properties on an object

Released under the MIT license.