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

filter followed by slice with negative begin not working #1992

Open
oloftus opened this issue Mar 23, 2024 · 2 comments
Open

filter followed by slice with negative begin not working #1992

oloftus opened this issue Mar 23, 2024 · 2 comments

Comments

@oloftus
Copy link

oloftus commented Mar 23, 2024

What happened

I would expect the following code

Immutable.Range(0, 10).filter($ => true).slice(-2).toArray()

to return

[8, 9]

but instead it returns

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

i.e. the slice operation is ignored.

If you remove the filter operation, the slice works as expected.

If you slice with a positive begin value, it works as expected.

How to reproduce

Run the above code snippets in the Chrome debug console on the immutable-js.com website, which embeds the Immutable library.

@sublimemm
Copy link

sublimemm commented Apr 6, 2024

image

just confirming.

@jdeniau
Copy link
Member

jdeniau commented Apr 19, 2024

You are right, this is a bug.
I will try to address that when I have the time.

If you are willing to investigate in the code to fix this, I would gladly accept a PR.

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