Skip to content

Doesn't memoize the result for keys returning undefined #66

@hargasinski

Description

@hargasinski

When the memoized function returns undefined for a specific parameter, another call to the memoized function runs the original function again as opposed to fetching the result from the cache.

Reproducible Example:

const memoize = require('fast-memoize')
const assert = require('assert')

let numCalled = 0
function longProcess(arg) {
  ++numCalled
  return
}

// memoize result
const memoizedProcess = memoize(longProcess)
memoizedProcess("foo")

// get memoized result
memoizedProcess("foo")
assert(numCalled === 1)

It seems like this changed from v2.2.8 to v2.3.0. Is this the intended behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions