diff --git a/.github/funding.yml b/.github/funding.yml deleted file mode 100644 index 15edf6e..0000000 --- a/.github/funding.yml +++ /dev/null @@ -1,4 +0,0 @@ -github: sindresorhus -open_collective: sindresorhus -patreon: sindresorhus -custom: https://sindresorhus.com/donate diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1870cf..441975c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,12 +10,10 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 - - 10 + - 16 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/index.js b/index.js index 5475518..6aac881 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,18 @@ -'use strict'; -const got = require('got'); +import got from 'got'; const statusCodes = { isUp: 1, isDown: 2, - invalidDomain: 3 + invalidDomain: 3, }; -module.exports = async url => { +export default async function isUp(url) { const hostname = encodeURIComponent((new URL(url)).hostname); const {status_code: statusCode} = await got(`https://isitup.org/${hostname}.json`, { headers: { - 'user-agent': 'https://github.com/sindresorhus/is-up' - } + 'user-agent': 'https://github.com/sindresorhus/is-up', + }, }).json(); if (statusCode === statusCodes.invalidDomain) { @@ -21,4 +20,4 @@ module.exports = async url => { } return statusCode === statusCodes.isUp; -}; +} diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) 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: diff --git a/package.json b/package.json index 91718b7..d02245f 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,12 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, + "type": "module", + "exports": "./index.js", "engines": { - "node": ">=10" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { "test": "xo && ava" @@ -31,11 +33,11 @@ "offline" ], "dependencies": { - "got": "^10.5.5" + "got": "^11.8.2" }, "devDependencies": { - "ava": "^1.0.0", - "unique-string": "^2.0.0", - "xo": "^0.25.4" + "ava": "^3.15.0", + "unique-string": "^3.0.0", + "xo": "^0.44.0" } } diff --git a/readme.md b/readme.md index 571baf0..0f03cb7 100644 --- a/readme.md +++ b/readme.md @@ -4,19 +4,17 @@ ## Install -``` -$ npm install is-up +```sh +npm install is-up ``` ## Usage ```js -const isUp = require('is-up'); +import isUp from 'is-up'; -(async () => { - console.log(await isUp('https://sindresorhus.com')); - //=> true -})(); +console.log(await isUp('https://sindresorhus.com')); +//=> true ``` ## Related diff --git a/test.js b/test.js index ff5573e..bf3ee13 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ import test from 'ava'; import uniqueString from 'unique-string'; -import isUp from '.'; +import isUp from './index.js'; test('up', async t => { t.true(await isUp('https://google.com')); @@ -11,5 +11,5 @@ test('down', async t => { }); test('invalid domain', async t => { - await t.throwsAsync(isUp('unicorn'), 'Invalid URL: unicorn'); + await t.throwsAsync(isUp('unicorn'), {message: 'Invalid URL'}); });