-
Notifications
You must be signed in to change notification settings - Fork 58
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
Feature request: pass picomatch to the builder #89
Comments
@glenn2223 I am not sure I see the benefit of exposing such an API. What's the difference between this and |
There are a few reasons to have this new API:
Examples (based on name new fdir()
// picomatch
.globUsing(picomatch('*.foo'))
// minimatch
.globUsing(new minimatch('*.foo').match)
// micromatch
.globUsing(micromatch.matcher('*.foo'))
// nanomatch
.globUsing(nanomatch.matcher('*.foo'))
// CUSTOM (just `endsWith`)
.globUsing(
(input: string) =>
input.endsWith('.foo') ||
input.endsWith('.bar')
)
// CUSTOM (function where other stuff can happen)
.globUsing(cM.matcher);
/* WHERE */ const cM = customMatcher('*.foo');
function customMatcher(pattern: string)
{
// Fake picomatch
const pM = ((pat) => (input: string) => input.endsWith(pat))(pattern),
checkedList: string[] = [],
matchList: string[] = [];
return { matcher, checkedList, matchList };
function matcher(input: string) {
checkedList.push(input);
const result = pM(input);
if (result) {
matchList.push(input);
}
return result;
}
}
// All this is based on:
export declare class Builder<TReturnType extends Output = PathsOutput> {
globUsing(matcher: Matcher): this;
}
export interface Matcher {
(test: string): boolean;
} Now, I know these can be implemented using the |
I'm landing at this issue due to bundling issues related to the dynamic requiring of |
i believe #98 implemented this, but the old |
It would be nice to be able to pass picomatch directly to fdir for better bundling/terser support.
Though I did notice you kind of mention it here, I just wanted to bring it up as a specific use-case feature request.
If I find time and you're open to the idea (to save wasted time 😂), I may be able to submit a PR.
I was thinking that this would have to be a new entry point to make the most sense, though caching becomes an issue. This method would allow for the best portability/adaptability and lean (sort of) towards the pluggability aspect. It would be something like:
If you'd rather have caching then you could extend the
globWithoptions
(though it's quite counterintuitive) or change the above method:The text was updated successfully, but these errors were encountered: