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

error messages not thrown on memoized calls #31

Closed
ChristopherChudzicki opened this issue Aug 28, 2018 · 0 comments
Closed

error messages not thrown on memoized calls #31

ChristopherChudzicki opened this issue Aug 28, 2018 · 0 comments

Comments

@ChristopherChudzicki
Copy link

memoizeOne seems not to throw errors when the function call is memoized.

For example, in the function below I would expect the second call to throwingDivide to throw an error, but it does not. Is this behavior expected?

var memoizeOne = require("memoize-one")

function _throwingDivide(x, y) {
  if (y===0) {
    throw Error('cannot divide by zero')
  }
  return x/y
}

const throwingDivide = memoizeOne(_throwingDivide)

try {
  throwingDivide(4, 0)
}
catch (error) {
  console.log(error)
}

console.log(throwingDivide(4, 0)) // does not throw !

Thanks for this library—love it's simplicity!

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

1 participant