Skip to content

Commit aebb6e8

Browse files
committed
Require Node.js 12 and move to ESM
1 parent 34ec4c6 commit aebb6e8

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

.github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
node-version:
1313
- 14
1414
- 12
15-
- 10
1615
steps:
1716
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
17+
- uses: actions/setup-node@v2
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

index.d.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ You can also use this to escape a string that is inserted into the middle of a r
55
66
@example
77
```
8-
import escapeStringRegexp = require('escape-string-regexp');
8+
import escapeStringRegexp from 'escape-string-regexp';
99
1010
const escapedString = escapeStringRegexp('How much $ for a 🦄?');
1111
//=> 'How much \\$ for a 🦄\\?'
1212
1313
new RegExp(escapedString);
1414
```
1515
*/
16-
declare const escapeStringRegexp: (string: string) => string;
17-
18-
export = escapeStringRegexp;
16+
export default function escapeStringRegexp(string: string): string;

index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = string => {
1+
export default function escapeStringRegexp(string) {
42
if (typeof string !== 'string') {
53
throw new TypeError('Expected a string');
64
}
@@ -10,4 +8,4 @@ module.exports = string => {
108
return string
119
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
1210
.replace(/-/g, '\\x2d');
13-
};
11+
}

index.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import {expectType} from 'tsd';
2-
import escapeStringRegexp = require('.');
2+
import escapeStringRegexp from './index.js';
33

44
expectType<string>(escapeStringRegexp('how much $ for a 🦄?'));

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"email": "[email protected]",
1111
"url": "https://sindresorhus.com"
1212
},
13+
"type": "module",
14+
"exports": "./index.js",
1315
"engines": {
14-
"node": ">=10"
16+
"node": ">=12"
1517
},
1618
"scripts": {
1719
"test": "xo && ava && tsd"
@@ -31,8 +33,8 @@
3133
"characters"
3234
],
3335
"devDependencies": {
34-
"ava": "^1.4.1",
35-
"tsd": "^0.11.0",
36-
"xo": "^0.28.3"
36+
"ava": "^3.15.0",
37+
"tsd": "^0.14.0",
38+
"xo": "^0.38.2"
3739
}
3840
}

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ npm install escape-string-regexp
1111
## Usage
1212

1313
```js
14-
const escapeStringRegexp = require('escape-string-regexp');
14+
import escapeStringRegexp from 'escape-string-regexp';
1515

1616
const escapedString = escapeStringRegexp('How much $ for a 🦄?');
1717
//=> 'How much \\$ for a 🦄\\?'

test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import escapeStringRegexp from '.';
2+
import escapeStringRegexp from './index.js';
33

44
test('main', t => {
55
t.is(

0 commit comments

Comments
 (0)