Memoize a function with argument equality
Cache function results using an injected positional equality strategy while preserving receiver semantics.Description
Requirements
The solution exports the required memoize API from the editable module.
Cache hit works deterministically for the documented normal, boundary, and repeated-use scenarios.
Cache miss works deterministically for the documented normal, boundary, and repeated-use scenarios.
Argument equality works deterministically for the documented normal, boundary, and repeated-use scenarios.
Preserves this works deterministically for the documented normal, boundary, and repeated-use scenarios.
Caches undefined works deterministically for the documented normal, boundary, and repeated-use scenarios.
Caller-owned inputs and nested values remain unchanged after the operation completes.
Custom object equality
Call twice with distinct { id: 7 } objects and equality comparing idThe wrapped function executes once and the second call reuses its result
Equality is applied position by position across the complete argument tuple.
Constraints
Preserve the original receiver on cache missesCache undefined resultsDo not mutate or freeze argument values
Hints
Hint 1
Store argument tuples separately from cached results.
Hint 2
A hit requires equal lengths and equality at every position.
Hint 3
Use an explicit found flag so undefined can represent a valid cached value.