escape-string-regexp
Advanced tools
Comparing version 4.0.0 to 5.0.0
@@ -8,3 +8,3 @@ /** | ||
``` | ||
import escapeStringRegexp = require('escape-string-regexp'); | ||
import escapeStringRegexp from 'escape-string-regexp'; | ||
@@ -17,4 +17,2 @@ const escapedString = escapeStringRegexp('How much $ for a 🦄?'); | ||
*/ | ||
declare const escapeStringRegexp: (string: string) => string; | ||
export = escapeStringRegexp; | ||
export default function escapeStringRegexp(string: string): string; |
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
module.exports = string => { | ||
export default function escapeStringRegexp(string) { | ||
if (typeof string !== 'string') { | ||
@@ -9,6 +7,6 @@ throw new TypeError('Expected a string'); | ||
// Escape characters with special meaning either inside or outside character sets. | ||
// Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. | ||
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. | ||
return string | ||
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') | ||
.replace(/-/g, '\\x2d'); | ||
}; | ||
} |
{ | ||
"name": "escape-string-regexp", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Escape RegExp special characters", | ||
@@ -13,4 +13,6 @@ "license": "MIT", | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=12" | ||
}, | ||
@@ -35,6 +37,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.28.3" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp) | ||
# escape-string-regexp | ||
@@ -14,3 +14,3 @@ > Escape RegExp special characters | ||
```js | ||
const escapeStringRegexp = require('escape-string-regexp'); | ||
import escapeStringRegexp from 'escape-string-regexp'; | ||
@@ -17,0 +17,0 @@ const escapedString = escapeStringRegexp('How much $ for a 🦄?'); |
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
Yes
3659
22