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

memoized function has no length #38

Open
ChristopherChudzicki opened this issue Oct 19, 2018 · 4 comments
Open

memoized function has no length #38

ChristopherChudzicki opened this issue Oct 19, 2018 · 4 comments

Comments

@ChristopherChudzicki
Copy link

Memoizing a function sets its length property to zero:

import memoizeOne from 'memoize-one'
f = (a, b, c) => a*b*c
memoF = memoizeOne(f)
console.log(f.length) // 3
console.log(memoF.length) // 0

This is not really a big deal: length is a configurable property, so if you care about f.length you can just set it manually afterwards using Object.definiteProperty.

Should memoizeOne automatically configure the memoized functions length property?

@alexreardon
Copy link
Owner

At one point we tried adding this, but it broke ie11 #18

We could wrap the assignment in a try / catch...

I am not sure what the best path forward is. /cc @theKashey

@theKashey
Copy link
Contributor

We shall just redo #18

@alexreardon
Copy link
Owner

Maybe if we wrap it in a try catch? My issue is that people might expect the function to have a length in ie11 - but it wont

@theKashey
Copy link
Contributor

theKashey commented Dec 18, 2018

There is 2 ways to define length

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