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: add times.atMost function #227

Merged
merged 3 commits into from
Feb 28, 2023
Merged

feat: add times.atMost function #227

merged 3 commits into from
Feb 28, 2023

Conversation

xRSquared
Copy link
Contributor

Add times.atMost function for matching an expression at most N times.

Usage

import { createRegExp, exactly } from 'magic-regexp'

const fooRegex = createRegExp(exactly('foo').times.atMost(2)) // (?:foo){0,2}

const fooOnce = 'foo'
const fooTwice = 'foofoo'
const fooThrice = 'foofoofoo'

const testOne = fooOnce.replace(fooRegex.toString(), 'bye') // bye
const testTwo = fooTwice.replace(fooRegex.toString(), 'bye') // bye
const testThree = fooThrice.replace(fooRegex.toString(), 'bye') // byefoo

@vercel
Copy link

vercel bot commented Feb 27, 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 Feb 27, 2023

  • Added atMost to the times function
  • Updated documentation for usage of times and added a test case for it

@xRSquared xRSquared changed the title feat: add test.atMost function feat: add times.atMost function Feb 28, 2023
@vercel
Copy link

vercel bot commented Feb 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
magic-regexp ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 28, 2023 at 9:59AM (UTC)

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great 👌 Thank you!

@danielroe danielroe merged commit b4e2aa2 into unjs:main Feb 28, 2023
@darsh-agrawal71
Copy link

When will this be added in the npm package?

Copy link
Member

Shortly 😊

@darsh-agrawal71
Copy link

thanks!

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.

None yet

3 participants