Skip to content

Commit

Permalink
Require Node.js 18 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 30, 2024
1 parent 4d30105 commit 7c9bae1
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 48 deletions.
2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 10
- 8
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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 @@ -3,7 +3,7 @@ Check if a file path is a binary file.
@example
```
import isBinaryPath = require('is-binary-path');
import isBinaryPath from 'is-binary-path';
isBinaryPath('source/unicorn.png');
//=> true
Expand All @@ -12,6 +12,4 @@ isBinaryPath('source/unicorn.txt');
//=> false
```
*/
declare function isBinaryPath(filePath: string): boolean;

export = isBinaryPath;
export default function isBinaryPath(filePath: string): boolean;
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
const path = require('path');
const binaryExtensions = require('binary-extensions');
import path from 'node:path';
import binaryExtensions from 'binary-extensions';

const extensions = new Set(binaryExtensions);

module.exports = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase());
export default function isBinaryPath(filePath) {
return extensions.has(path.extname(filePath).slice(1).toLowerCase());
}
4 changes: 0 additions & 4 deletions index.test-d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com), Paul Miller (https://paulmillr.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Copyright (c) Paul Miller (https://paulmillr.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:

Expand Down
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
"description": "Check if a file path is a binary file",
"license": "MIT",
"repository": "sindresorhus/is-binary-path",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"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"
},
"files": [
"index.js",
Expand All @@ -30,11 +37,10 @@
"is"
],
"dependencies": {
"binary-extensions": "^2.0.0"
"binary-extensions": "^3.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^6.1.2",
"xo": "^0.58.0"
}
}
22 changes: 3 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

> Check if a file path is a binary file

## Install

```
$ npm install is-binary-path
```sh
npm install is-binary-path
```


## Usage

```js
const isBinaryPath = require('is-binary-path');
import isBinaryPath from 'is-binary-path';

isBinaryPath('source/unicorn.png');
//=> true
Expand All @@ -22,21 +20,7 @@ isBinaryPath('source/unicorn.txt');
//=> false
```


## Related

- [binary-extensions](https://github.com/sindresorhus/binary-extensions) - List of binary file extensions
- [is-text-path](https://github.com/sindresorhus/is-text-path) - Check if a filepath is a text file


---

<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-is-binary-path?utm_source=npm-is-binary-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
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 isBinaryPath from '.';
import isBinaryPath from './index.js';

test('main', t => {
t.true(isBinaryPath('unicorn.png'));
Expand Down

0 comments on commit 7c9bae1

Please sign in to comment.