Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "is-regexy", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Check if a string could be a regular expression", | ||
@@ -8,5 +8,3 @@ "main": "index.js", | ||
"test": "jest", | ||
"test:coverage": "jest --collectCoverage", | ||
"codecov": "codecov", | ||
"semantic-release": "semantic-release" | ||
"test:coverage": "jest --collectCoverage" | ||
}, | ||
@@ -36,6 +34,4 @@ "repository": { | ||
"devDependencies": { | ||
"codecov": "^3.6.5", | ||
"jest": "^25.3.0", | ||
"semantic-release": "^17.0.6" | ||
"jest": "^25.3.0" | ||
} | ||
} |
@@ -1,1 +0,25 @@ | ||
# is-regexy | ||
# is-regexy ![npm](https://img.shields.io/npm/v/is-regexy) ![Travis (.org)](https://img.shields.io/travis/lekterable/is-regexy) [![codecov](https://codecov.io/gh/lekterable/is-regexy/branch/master/graph/badge.svg)](https://codecov.io/gh/lekterable/is-regexy) [![management: perfekt👌](https://img.shields.io/badge/management-perfekt👌-red.svg?style=flat-square)](https://github.com/lekterable/perfekt) | ||
A very simple library for checking if given value (Regex object OR string) could be a valid regular expression. | ||
Useful when we want to allow users to pass regex patterns as user input. | ||
## Example | ||
```js | ||
const isRegex = require('is-regex') // CommonJS | ||
// OR | ||
import isRegex from 'is-regex' // ES modules | ||
isRegex('foo') // false | ||
isRegex(/foo/) // true | ||
isRegex(new RegExp('foo')) // true | ||
isRegex('/foo/') // true | ||
isRegex('/foo/ig') // true | ||
isRegexy('/(epic|feat|fix|chore)/DEV-\\d{4}/i') //true | ||
``` | ||
## License | ||
[MIT](LICENSE) |
@@ -5,10 +5,22 @@ const isRegexy = require('../') | ||
it('should validate Regex object', () => { | ||
expect(isRegexy(new RegExp('development'))).toBe(true) | ||
}) | ||
it('should validate Regex object with flag', () => { | ||
expect(isRegexy(new RegExp('development', 'i'))).toBe(true) | ||
}) | ||
it('should validate Regex object with multiple flags', () => { | ||
expect(isRegexy(new RegExp('development', 'gi'))).toBe(true) | ||
}) | ||
it('should validate Regex pattern', () => { | ||
expect(isRegexy(/development/)).toBe(true) | ||
}) | ||
it('should validate Regex object with flag', () => { | ||
it('should validate Regex pattern with flag', () => { | ||
expect(isRegexy(/development/i)).toBe(true) | ||
}) | ||
it('should validate Regex object with multiple flags', () => { | ||
it('should validate Regex pattern with multiple flags', () => { | ||
expect(isRegexy(/development/gi)).toBe(true) | ||
@@ -25,2 +37,6 @@ }) | ||
it('should validate complex Regex string', () => { | ||
expect(isRegexy('/(epic|feat|fix|chore)/DEV-\\d{4}/i')).toBe(true) | ||
}) | ||
it('should validate Regex string with flag', () => { | ||
@@ -27,0 +43,0 @@ expect(isRegexy('/development/i')).toBe(true) |
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
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
6644
1
8
41
26