Skip to content

Commit 3ced641

Browse files
committed
Require Node.js 12.20 and move to ESM
1 parent 26088da commit 3ced641

File tree

7 files changed

+24
-31
lines changed

7 files changed

+24
-31
lines changed

.github/funding.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
14-
- 12
15-
- 10
13+
- 16
1614
steps:
1715
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
16+
- uses: actions/setup-node@v2
1917
with:
2018
node-version: ${{ matrix.node-version }}
2119
- run: npm install

index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
'use strict';
2-
const got = require('got');
1+
import got from 'got';
32

43
const statusCodes = {
54
isUp: 1,
65
isDown: 2,
7-
invalidDomain: 3
6+
invalidDomain: 3,
87
};
98

10-
module.exports = async url => {
9+
export default async function isUp(url) {
1110
const hostname = encodeURIComponent((new URL(url)).hostname);
1211

1312
const {status_code: statusCode} = await got(`https://isitup.org/${hostname}.json`, {
1413
headers: {
15-
'user-agent': 'https://github.com/sindresorhus/is-up'
16-
}
14+
'user-agent': 'https://github.com/sindresorhus/is-up',
15+
},
1716
}).json();
1817

1918
if (statusCode === statusCodes.invalidDomain) {
2019
throw new Error('Invalid domain');
2120
}
2221

2322
return statusCode === statusCodes.isUp;
24-
};
23+
}

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
"author": {
99
"name": "Sindre Sorhus",
1010
"email": "[email protected]",
11-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1212
},
13+
"type": "module",
14+
"exports": "./index.js",
1315
"engines": {
14-
"node": ">=10"
16+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
1517
},
1618
"scripts": {
1719
"test": "xo && ava"
@@ -31,11 +33,11 @@
3133
"offline"
3234
],
3335
"dependencies": {
34-
"got": "^10.5.5"
36+
"got": "^11.8.2"
3537
},
3638
"devDependencies": {
37-
"ava": "^1.0.0",
38-
"unique-string": "^2.0.0",
39-
"xo": "^0.25.4"
39+
"ava": "^3.15.0",
40+
"unique-string": "^3.0.0",
41+
"xo": "^0.44.0"
4042
}
4143
}

readme.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44
55
## Install
66

7-
```
8-
$ npm install is-up
7+
```sh
8+
npm install is-up
99
```
1010

1111
## Usage
1212

1313
```js
14-
const isUp = require('is-up');
14+
import isUp from 'is-up';
1515

16-
(async () => {
17-
console.log(await isUp('https://sindresorhus.com'));
18-
//=> true
19-
})();
16+
console.log(await isUp('https://sindresorhus.com'));
17+
//=> true
2018
```
2119

2220
## Related

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22
import uniqueString from 'unique-string';
3-
import isUp from '.';
3+
import isUp from './index.js';
44

55
test('up', async t => {
66
t.true(await isUp('https://google.com'));
@@ -11,5 +11,5 @@ test('down', async t => {
1111
});
1212

1313
test('invalid domain', async t => {
14-
await t.throwsAsync(isUp('unicorn'), 'Invalid URL: unicorn');
14+
await t.throwsAsync(isUp('unicorn'), {message: 'Invalid URL'});
1515
});

0 commit comments

Comments
 (0)