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

Using matcher inside Array.filter doesn't work #206

Open
XxSven opened this issue Jul 10, 2020 · 3 comments
Open

Using matcher inside Array.filter doesn't work #206

XxSven opened this issue Jul 10, 2020 · 3 comments

Comments

@XxSven
Copy link

XxSven commented Jul 10, 2020

Please describe the minimum necessary steps to reproduce this issue:

Use matcher inside Array.filter function
['a','b','c'].filter(mm.matcher('b'));

What is happening that shouldn't be?

Array is not filtered
Result should be ['b']

What should be happening instead?

Array should be filtered
Result is ['b', 'c']

Array.filter gives value and index as arguments, so it gives matcher function the index as returnedObject value
image

@jonschlinkert
Copy link
Member

Do:

const matcher = mm.matcher('b');
['a','b','c'].filter(input => matcher(input)));

@XxSven
Copy link
Author

XxSven commented Jul 10, 2020

This is a good workaround but shouldn't it work as mm.filter that was deleted from previous versions ?

@jonschlinkert
Copy link
Member

This is a good workaround but shouldn't it work as mm.filter that was deleted from previous versions ?

No, there was no promise of parity with .filter().

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