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

feat: lazy quantifier helper input #281

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

didavid61202
Copy link
Collaborator

@didavid61202 didavid61202 commented Mar 30, 2023

Update

add lazy quantifier version of original input helpers:

  • add times.anyLazy, times.atLeastLazy, times.atMostLazy and times.betweenLazy under times chain helper.
  • add maybeLazy and oneOrMoreLazy, two creating helpers.

Request for Input and Discussion

Lazy quantifier functionality is easy to implement, but the current naming for new helpers might not be the best naming option.

Currently, I've thought of 3 naming pattern for lazy quantifier:

  1. Suffix Lazy to the name of original greedy version helpers (current implementation), eg: times.anyLazy().
    • Pro: This option group/display lazy inputs adjacent to its corresponding greedy version when shown in IDE hints/autocompletes
    • Con: not very intuitive, and might cause confusion
  2. Prefix Lazy to the name of original greedy version helpers, eg: times.LazyAny().
  • Pro: more intuitive compared to option 1, less confusing at conveying the functionality.
    (after some thought, I prefer this option more)
  1. add an additional option argument to the input, eg: times.any({ greedy : false }) and maybe(<str>,{ greedy : false })
    • Pro: Not adding new helper inputs, less cluttering to the API
    • Con: different config style that users have to learn/know, less discoverable compare to option 1 & option 2.

need some input before finalizing the naming and adding documentation.

Usage

    const val = exactly('a').times.between(3, 5)
    const regexp = new RegExp(val as any)
    expect(regexp).toMatchInlineSnapshot('/a\\{3,5\\}\\?/')
    expectTypeOf(extractRegExp(val)).toEqualTypeOf<'a{3,5}?'>()

Resolve

resolve #228

  • add/update tests
  • update docs
  • finalize naming

@vercel
Copy link

vercel bot commented Mar 30, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @danielroe on Vercel.

@danielroe first needs to authorize it.

@what-the-diff
Copy link

what-the-diff bot commented Mar 30, 2023

PR Summary

  • Added lazy mode to repeatable inputs
    Introduces a lazy mode feature for all repetitive input fields, improving efficiency and performance.
  • Fixed export issue in inputs.ts
    Resolved an issue in inputs.ts where some functions, such as maybeLazy, were not being exported properly.

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

Successfully merging this pull request may close these issues.

Lazy quantifier
1 participant