-
-
Notifications
You must be signed in to change notification settings - Fork 58
feat: variadic input helpers #284
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
feat: variadic input helpers #284
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @danielroe on Vercel. @danielroe first needs to authorize it. |
PR Summary
|
PR Summary
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #284 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 467 520 +53
Branches 82 87 +5
=========================================
+ Hits 467 520 +53
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I really like this ❤️ It makes writing regexp much less verbose - great DX. |
@danielroe Thanks! |
Using variadic functions is an elegant solution. I love it! |
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Daniel Roe <daniel@roe.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Update & Proposal
Update input helpers to take variadic arguments, eg:
exactly('foo', maybe('bar'), 'baz'...)
, enabling a more concise syntax and improving the overall readability of the code.Currently, the input helpers take only one argument of either type
string
or anotherInput
. To concatenate different RegExp patterns, users need to use the.and()
chaining helper repeatedly. This approach is very descriptive but can also make the code verbose and difficult to read when dealing with multiple input helpers in more complex scenario.To improve the syntax and readability, I want to propose an update to all input helpers to variadic function that take one or more
string
orInput
as arguments.And this update will maintain backward compatibility, as the new helpers still accept a single argument of type
string
orInput
, and still can chain using.and()
. However, users will also have the option to pass multiple arguments to the functions, which will be concatenated accordingly.please let me know your suggestion, feedback, and input.
Updated inputs
createRegExp
(last array arg as flags)maybe
exactly
oneOrMore
.and
.or
.after
.before
.notAfter
.notBefore
Example
original
semver
examplewith this update, can be simplified to:
Related issues
#237