Skip to content

Commit

Permalink
Require Node.js 18 and move to ESM
Browse files Browse the repository at this point in the history
Closes #29
  • Loading branch information
sindresorhus committed Apr 30, 2024
1 parent 3ad032e commit 4fe3190
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 10
- 8
- 20
- 18
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
3 changes: 0 additions & 3 deletions binary-extensions.json.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ List of binary file extensions.
@example
```
import binaryExtensions = require('binary-extensions');
import binaryExtensions from 'binary-extensions';
console.log(binaryExtensions);
//=> ['3ds', '3g2', …]
```
*/
declare const binaryExtensions: readonly string[];

export = binaryExtensions;
export default binaryExtensions;
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = require('./binary-extensions.json');
import binaryExtensions from './binary-extensions.json' with {type: 'json'};

export default binaryExtensions;
4 changes: 1 addition & 3 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {expectType} from 'tsd';
import binaryExtensions = require('.');
import binaryExtensionsJson = require('./binary-extensions.json');
import binaryExtensions from './index.js';

expectType<readonly string[]>(binaryExtensions);
expectType<readonly string[]>(binaryExtensionsJson);
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@
"email": "[email protected]",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=8"
"node": ">=18.20"
},
"scripts": {
"test": "xo && ava && tsd"
"//test": "xo && ava && tsd",
"test": "ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"binary-extensions.json",
"binary-extensions.json.d.ts"
"binary-extensions.json"
],
"keywords": [
"binary",
Expand All @@ -33,8 +38,8 @@
"array"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^6.1.2",
"tsd": "^0.31.0",
"xo": "^0.58.0"
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ npm install binary-extensions
## Usage

```js
const binaryExtensions = require('binary-extensions');
import binaryExtensions from 'binary-extensions';

console.log(binaryExtensions);
//=> ['3ds', '3g2', …]
```

## Related

- [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a filepath is a binary file
- [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a file path is a binary file
- [text-extensions](https://github.com/sindresorhus/text-extensions) - List of text file extensions
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import binaryExtensions from '.';
import binaryExtensions from './index.js';

test('main', t => {
t.true(Array.isArray(binaryExtensions));
Expand Down

0 comments on commit 4fe3190

Please sign in to comment.