Skip to content

Commit ed0c5d2

Browse files
authored
Require Node.js 12.20 and move to ESM (#6)
1 parent 6048b5f commit ed0c5d2

File tree

7 files changed

+18
-25
lines changed

7 files changed

+18
-25
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 16
1314
- 14
1415
- 12
15-
- 10
16-
- 8
1716
steps:
1817
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
2019
with:
2120
node-version: ${{ matrix.node-version }}
2221
- run: npm install

index.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ Humanize a URL: `https://sindresorhus.com` → `sindresorhus.com`.
33
44
@example
55
```
6-
import humanizeUrl = require('humanize-url');
6+
import humanizeUrl from 'humanize-url';
77
88
humanizeUrl('https://www.sindresorhus.com/');
99
//=> 'sindresorhus.com'
1010
```
1111
*/
12-
declare function humanizeUrl(url: string): string;
13-
14-
export = humanizeUrl;
12+
export default function humanizeUrl(url: string): string;

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict';
2-
const normalizeUrl = require('normalize-url');
1+
import normalizeUrl from 'normalize-url';
32

4-
module.exports = url => {
3+
export default function humanizeUrl(url) {
54
if (typeof url !== 'string') {
65
throw new TypeError('Expected a string');
76
}
87

98
return normalizeUrl(url, {stripProtocol: true});
10-
};
9+
}

index.test-d.ts

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

44
expectType<string>(humanizeUrl('https://www.sindresorhus.com/'));

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"author": {
88
"name": "Sindre Sorhus",
99
"email": "[email protected]",
10-
"url": "sindresorhus.com"
10+
"url": "https://sindresorhus.com"
1111
},
12+
"type": "module",
13+
"exports": "./index.js",
1214
"engines": {
13-
"node": ">=8"
15+
"node": ">=12.20"
1416
},
1517
"scripts": {
1618
"test": "xo && ava && tsd"
@@ -39,11 +41,11 @@
3941
"prettify"
4042
],
4143
"dependencies": {
42-
"normalize-url": "^4.5.1"
44+
"normalize-url": "^7.0.0"
4345
},
4446
"devDependencies": {
45-
"ava": "^1.4.1",
46-
"tsd": "^0.7.2",
47-
"xo": "^0.24.0"
47+
"ava": "^3.15.0",
48+
"tsd": "^0.17.0",
49+
"xo": "^0.41.0"
4850
}
4951
}

readme.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ $ npm install humanize-url
1313
## Usage
1414

1515
```js
16-
const humanizeUrl = require('humanize-url');
16+
import humanizeUrl from 'humanize-url';
1717

1818
humanizeUrl('https://www.sindresorhus.com/');
1919
//=> 'sindresorhus.com'
2020
```
21-
22-
23-
## License
24-
25-
MIT © [Sindre Sorhus](https://sindresorhus.com)

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 humanizeUrl from '.';
2+
import humanizeUrl from './index.js';
33

44
test('main', t => {
55
t.is(humanizeUrl('http://sindresorhus.com'), 'sindresorhus.com');

0 commit comments

Comments
 (0)