-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feedback #1
Comments
Are the docs clear enough?Clean and good examples. I like it :). API nice enough? Anything missing?What about making it possible to pass in a string as second argument of matcher(['foo', 'bar', 'moo'], '!*oo'); Any suggestions for better method name than
|
Thanks for the feedback Sam :)
I've gone back and forth on that. On one hand, it's a nice flexibility, on another, it's also nice with consistency and the clarity of what it accepts. When someone reads
Hah, yeah I considered
Do you have an actual need for that? I usually prefer waiting on adding options until there are real-world needs. |
RTFM :). But we all know how that goes for users ;).
Not at the moment. Maybe just wait for that until someone needs it and creates an issue. |
Sure, that will always be needed. I'm just considering whether the slight convenience is worth the resulting slightly less readable code.
I got |
I used the module a minute a go and maybe got a little confused because of this matcher(['foo', 'bar', 'moo'], ['!*oo']); // (input, pattern)
matcher.isMatch('uni*', 'unicorn'); // (pattern, input) While the docs state
The real implementation of |
Oops, I forgot to update the usage examples. Implementation and API docs are correct. Fixed. |
^ That is definitely confusing. Does this module accept |
No, why would it? The whole point of this module is not having to use regex for simple matching. |
To be able to filter out entries in an array given a regex. That'd be useful. |
['foo', 'bar', 'moo'].filter(x => /.*oo/.test(x)); |
That works I suppose. |
Yeah, I prefer to keep this module focused on doing one thing well. Especially since matching against a regexes I so simple to do in vanilla JS. |
A completely different way to go with the API: import matcher from 'matcher';
const startsWithFoo = matcher('foo*');
['foo', 'late foo', 'bar'].filter(startsWithFoo);
if (startsWIthFoo(str)) {
// ...
} |
@jamestalmage Yeah, I considered a I initially had the order of Do you think it makes sense that the main method is the filtering logic? Or should it have been |
Why can't negation and arrays of patterns be used in the factory method as well? const m1 = matcher(['foo*', '!foobar*']); If you can make the factory method work, and it's performant - I'd like it to be the one and only option. No sense in a filter method at that point, since you can just use.the native array filter. |
Very nice, I once was just about to create something like this.
I'd personally prefer |
The filtering is dependent on the input: Lines 48 to 50 in 6337958
[].filter() .
|
What about |
@stevemao I made |
I could use some feedback on the API, docs, and code.
Are the docs clear enough? API nice enough? Anything missing? Any suggestions for better method name than
matcher.isMatch()
?Currently the matching is case-insensitive? Is this a good default? Should there be an option to toggle this?
The text was updated successfully, but these errors were encountered: