diff --git a/.github/funding.yml b/.github/funding.yml deleted file mode 100644 index 1a630e9..0000000 --- a/.github/funding.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: sindresorhus -open_collective: sindresorhus -custom: https://sindresorhus.com/donate diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1870cf..d36e1a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,10 +12,9 @@ jobs: node-version: - 14 - 12 - - 10 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.d.ts b/index.d.ts index 42db357..bb7466d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,7 +5,7 @@ No other code will execute while it's sleeping, not even asynchronous code. @example ``` -import sleepSynchronously = require('sleep-synchronously'); +import sleepSynchronously from 'sleep-synchronously'; console.log(new Date()); //=> Sun Aug 16 2020 14:28:54 GMT+0200 (Central European Summer Time) @@ -16,6 +16,4 @@ console.log(new Date()); //=> Sun Aug 16 2020 14:28:56 GMT+0200 (Central European Summer Time) ``` */ -declare function sleepSynchronously(milliseconds: number): void; - -export = sleepSynchronously; +export default function sleepSynchronously(milliseconds: number): void; diff --git a/index.js b/index.js index 2a55691..2e88b12 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -'use strict'; - -module.exports = milliseconds => { +export default function sleepSynchronously(milliseconds) { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds); -}; +} diff --git a/index.test-d.ts b/index.test-d.ts index 5d4e4b8..047ec13 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,5 @@ import {expectType} from 'tsd'; -import sleepSynchronously = require('.'); +import sleepSynchronously from './index.js'; +// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression expectType(sleepSynchronously(200)); diff --git a/package.json b/package.json index 5e3ddd0..89f9af5 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,10 @@ "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, + "type": "module", + "exports": "./index.js", "engines": { - "node": ">=10" + "node": ">=12" }, "scripts": { "test": "xo && ava && tsd" @@ -35,10 +37,10 @@ "timeout" ], "devDependencies": { - "ava": "^2.4.0", - "in-range": "^2.0.0", - "time-span": "^4.0.0", - "tsd": "^0.13.1", - "xo": "^0.33.0" + "ava": "^3.15.0", + "in-range": "^3.0.0", + "time-span": "^5.0.0", + "tsd": "^0.14.0", + "xo": "^0.38.2" } } diff --git a/readme.md b/readme.md index cdf05f0..95e9599 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ $ npm install sleep-synchronously ## Usage ```js -const sleepSynchronously = require('sleep-synchronously'); +import sleepSynchronously from 'sleep-synchronously'; console.log(new Date()); //=> Sun Aug 16 2020 14:28:54 GMT+0200 (Central European Summer Time) diff --git a/test.js b/test.js index d2d17e9..92c31b1 100644 --- a/test.js +++ b/test.js @@ -1,7 +1,7 @@ -import {serial as test} from 'ava'; +import test from 'ava'; import timeSpan from 'time-span'; import inRange from 'in-range'; -import sleepSynchronously from '.'; +import sleepSynchronously from './index.js'; test('main', t => { const end = timeSpan();