Socket
Socket
Sign inDemoInstall

escape-string-regexp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escape-string-regexp - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

6

index.d.ts

@@ -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 🦄?');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc