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

Something weird happens with boolean functions applied to over #33

Closed
kutyel opened this issue Oct 4, 2020 · 3 comments
Closed

Something weird happens with boolean functions applied to over #33

kutyel opened this issue Oct 4, 2020 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed released

Comments

@kutyel
Copy link
Owner

kutyel commented Oct 4, 2020

https://codesandbox.io/s/opticsjs-example-ov3ll?file=/src/index.js

@kutyel kutyel added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers hacktoberfest labels Oct 4, 2020
@serras
Copy link
Collaborator

serras commented Oct 4, 2020

I am pretty sure it's something related to this line, which reads:

obj => (isNotFound(obj) ? notFound : obj[key] || notFound),

That obj[key] || notFound is there to cover the case in which key is not a property of obj, but it will also catch the case in which obj[key] is false, returning notFound then.

@kutyel
Copy link
Owner Author

kutyel commented Oct 4, 2020

this simple test does not pass:

  test('over should work with boolean functions', () => {
    const neg = x => !x
    const liked = { liked: true }
    const lens = optic('liked')

    expect(view(lens, liked)).toBe(true)
    expect(view(lens, over(lens, neg, liked))).toBe(false)
  })

@kutyel kutyel closed this as completed in 65f8b41 Oct 4, 2020
@github-actions
Copy link

github-actions bot commented Oct 4, 2020

🎉 This issue has been resolved in version 2.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed released
Projects
None yet
Development

No branches or pull requests

2 participants