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

Scope Issue #13

Open
anywhichway opened this issue Jun 16, 2023 · 4 comments
Open

Scope Issue #13

anywhichway opened this issue Jun 16, 2023 · 4 comments

Comments

@anywhichway
Copy link

Won't this fail if someone has memoized a method on an object and called it on the object?

node = {
			args: args,

			// Generate the result from original function
			val: fn.apply(null, args),
		};
@aduth
Copy link
Owner

aduth commented Jun 17, 2023

I'm not sure I follow the concern. Could you provide a sample code snippet of a memize-memoized function result which demonstrates the issue?

@anywhichway
Copy link
Author

sure! ... not that you would ever write and memoize the below, but it illustrates the point

const o = {
    length: 10,
    width: 10,
    height: 10,
    volume() { return this.length * this.width * this.height; }
}
o.volume = memize(0.volume);
v.volume(); // will throw because this is null

@aduth
Copy link
Owner

aduth commented Jun 18, 2023

Ah, yeah, I see the issue now. On first glance, I'd wonder if it'd be fine enough to swap out null with this, but I'd need to write some tests to confirm, and check for any potential performance impact.

@anywhichway
Copy link
Author

anywhichway commented Jun 18, 2023 via email

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

2 participants