Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 14, 2021
1 parent d3e3438 commit 20a8c83
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .github/funding.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = milliseconds => {
export default function sleepSynchronously(milliseconds) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
};
}
3 changes: 2 additions & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -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<void>(sleepSynchronously(200));
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 20a8c83

Please sign in to comment.