Skip to content

Commit

Permalink
feat: support string/Set as flags from createRegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jul 19, 2022
1 parent f058426 commit 231dfa1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import type { MagicRegExp, MagicRegExpMatchArray } from './core/types/magic-rege

export const createRegExp = <Value extends string, NamedGroups extends string = never>(
raw: Input<Value, NamedGroups> | Value,
flags?: Flag[]
) => new RegExp(exactly(raw).toString(), flags?.join('')) as MagicRegExp<`/${Value}/`, NamedGroups>
flags?: Flag[] | string | Set<Flag>
) =>
new RegExp(exactly(raw).toString(), [...(flags || '')].join('')) as MagicRegExp<
`/${Value}/`,
NamedGroups
>

export * from './core/flags'
export * from './core/inputs'
Expand Down

1 comment on commit 231dfa1

@vercel
Copy link

@vercel vercel bot commented on 231dfa1 Jul 19, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.