Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions called with deeply equal arguments (and deepEqual=true) seemingly not being memoized #73

Closed
tnrich opened this issue Mar 13, 2016 · 2 comments

Comments

@tnrich
Copy link

tnrich commented Mar 13, 2016

Hey there @erikras,

Thanks for the great tool. I'm having an issue where calling my memoized function with deeply nested objects that are deeply equal and having the deepEqual option set to true still results in a new function call.

Here's an example of this happening:

var lruMemoize = require("lru-memoize")
function test(options) {
    console.log('HELLO WORLD');
    return 'hello'
}

var mTest = lruMemoize(1,undefined,true)(test)

mTest({
    a: {
        yup: 'nope'
    },
    b: {
        well: 'no'
    }
})
mTest({
    a: {
        yup: 'nope'
    },
    b: {
        well: 'no'
    }
})

In this case "Hello World" is output to the console twice, instead of just once.

Any help solving this would be appreciated. Thanks!
Thomas

@oculus42
Copy link
Contributor

The way the config is handled, it doesn't handle the undefined value for the equal function. If you remove the undefined, this will work. It would be nice if it supported the undefined, as well.

erikras added a commit that referenced this issue Apr 18, 2017
Support undefined equal argument; Fixes #73
@erikras
Copy link
Owner

erikras commented Apr 18, 2017

Published fix in v1.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants