2.0.0 • Published 3 years ago

is-supported-regexp-flag v2.0.0

Weekly downloads
604,084
License
MIT
Repository
github
Last release
3 years ago

is-supported-regexp-flag

Check whether a RegExp flag is supported

Install

$ npm install is-supported-regexp-flag

Usage

import isSupportedRegexpFlag from 'is-supported-regexp-flag';

isSupportedRegexpFlag('g'); // As in `/foo/g`
//=> true

isSupportedRegexpFlag('u');
//=> false

The RegExp constructor throws if you're trying to use unsupported flags. This is a nicer way to check for support.