Skip to content

Commit 27dcda1

Browse files
committed
Require Node.js 12 and move to ESM
1 parent cd72e39 commit 27dcda1

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Check if a string is a URL.
33
44
@example
55
```
6-
import isUrl = require('is-url-superb');
6+
import isUrl from 'is-url-superb';
77
88
isUrl('https://sindresorhus.com');
99
//=> true
@@ -15,6 +15,4 @@ isUrl('unicorn');
1515
//=> false
1616
```
1717
*/
18-
declare function isUrl(url: string): boolean;
19-
20-
export = isUrl;
18+
export default function isUrl(url: string): boolean;

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = string => {
1+
export default function isUrl(string) {
42
if (typeof string !== 'string') {
53
throw new TypeError('Expected a string');
64
}
@@ -16,4 +14,4 @@ module.exports = string => {
1614
} catch {
1715
return false;
1816
}
19-
};
17+
}

index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import {expectType} from 'tsd';
2-
import isUrlSuperb = require('.');
2+
import isUrl from './index.js';
33

4-
expectType<boolean>(isUrlSuperb('https://sindresorhus.com'));
4+
expectType<boolean>(isUrl('https://sindresorhus.com'));

package.json

Lines changed: 6 additions & 4 deletions
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"
@@ -29,8 +31,8 @@
2931
"is"
3032
],
3133
"devDependencies": {
32-
"ava": "^2.4.0",
33-
"tsd": "^0.13.1",
34-
"xo": "^0.35.0"
34+
"ava": "^3.15.0",
35+
"tsd": "^0.14.0",
36+
"xo": "^0.38.2"
3537
}
3638
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ npm install is-url-superb
1111
## Usage
1212

1313
```js
14-
const isUrl = require('is-url-superb');
14+
import isUrl from 'is-url-superb';
1515

1616
isUrl('https://sindresorhus.com');
1717
//=> true

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import isUrl from '.';
2+
import isUrl from './index.js';
33

44
test('main', t => {
55
t.true(isUrl('https://sindresorhus.com'));

0 commit comments

Comments
 (0)