-
Notifications
You must be signed in to change notification settings - Fork 86
allows memoization of circular structures #23
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too familiar with the source, so I unfortunately can't comment on the other changes.
@@ -3,3 +3,4 @@ node_modules/ | |||
npm-debug.log | |||
.DS_Store | |||
coverage/ | |||
.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline at EOF. Reasoning
delete this.cache[key] | ||
} | ||
} | ||
|
||
const cacheDefault = { | ||
create: () => new ObjectWithoutPrototypeCache() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EOF
allows memoization of circular structures
test('memoize circular JSON', function () {
var circular = {
a: 'foo'
}
circular.b = circular
function circularFunction(a) {
return a.a
}
var memoizedCircularFunction = memoize(circularFunction)
// Assertions
expect(memoizedCircularFunction(circular)).toBe("foo")
expect(memoizedCircularFunction(circular)).toBe("foo")
})