is-supported-regexp-flag
Advanced tools
Comparing version 1.0.1 to 2.0.0
16
index.js
@@ -1,12 +0,8 @@ | ||
'use strict'; | ||
module.exports = function (flag) { | ||
var supported = true; | ||
export default function isSupportedRegexpFlag(flag) { | ||
try { | ||
new RegExp('', flag); | ||
} catch (err) { | ||
supported = false; | ||
new RegExp('', flag); // eslint-disable-line no-new | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
return supported; | ||
}; | ||
} |
{ | ||
"name": "is-supported-regexp-flag", | ||
"version": "1.0.1", | ||
"description": "Check whether a RegExp flag is supported. Mostly useful for `y` and `u`.", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-supported-regexp-flag", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"regexp", | ||
"regex", | ||
"re", | ||
"check", | ||
"is", | ||
"support", | ||
"supported", | ||
"valid", | ||
"flag" | ||
], | ||
"devDependencies": { | ||
"mocha": "*" | ||
} | ||
"name": "is-supported-regexp-flag", | ||
"version": "2.0.0", | ||
"description": "Check whether a RegExp flag is supported", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-supported-regexp-flag", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12.20" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"regexp", | ||
"regex", | ||
"check", | ||
"is", | ||
"support", | ||
"supported", | ||
"valid", | ||
"flag" | ||
], | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"xo": "^0.42.0" | ||
} | ||
} |
@@ -1,19 +0,17 @@ | ||
# is-supported-regexp-flag [![Build Status](https://travis-ci.org/sindresorhus/is-supported-regexp-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/is-supported-regexp-flag) | ||
# is-supported-regexp-flag | ||
> Check whether a RegExp flag is supported. Mostly useful for `y` and `u`. | ||
> Check whether a RegExp flag is supported | ||
## Install | ||
```sh | ||
$ npm install --save is-supported-regexp-flag | ||
``` | ||
$ npm install is-supported-regexp-flag | ||
``` | ||
## Usage | ||
```js | ||
var isSupportedRegexpFlag = require('is-supported-regexp-flag'); | ||
import isSupportedRegexpFlag from 'is-supported-regexp-flag'; | ||
isSupportedRegexpFlag('g'); // as in /foo/g | ||
isSupportedRegexpFlag('g'); // As in `/foo/g` | ||
//=> true | ||
@@ -25,7 +23,2 @@ | ||
RegExp throws if you're trying to use unsupported flags. This is a nicer way to check for support. | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
The `RegExp` constructor throws if you're trying to use unsupported flags. This is a nicer way to check for support. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Yes
2346
2
8
24