Skip to content

Commit

Permalink
Use a Set and ES2015ify (#2)
Browse files Browse the repository at this point in the history
* Use a `Set` and ES2015ify

Fixes #1.

* Inline return

* Meta tweaks

* Add XO
  • Loading branch information
kevva authored and sindresorhus committed Sep 14, 2016
1 parent 7a60b54 commit 0ad27ac
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 36 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
13 changes: 0 additions & 13 deletions .jshintrc

This file was deleted.

5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
- '6'
- '4'
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
'use strict';
var path = require('path');
var binaryExtensions = require('binary-extensions');
var exts = Object.create(null);
const path = require('path');
const binaryExtensions = require('binary-extensions');

binaryExtensions.forEach(function (el) {
exts[el] = true;
});
const exts = new Set(binaryExtensions);

module.exports = function (filepath) {
return path.extname(filepath).slice(1).toLowerCase() in exts;
};
module.exports = filepath => exts.has(path.extname(filepath).slice(1).toLowerCase());
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "ava"
"test": "xo && ava"
},
"files": [
"index.js"
Expand All @@ -34,6 +34,10 @@
"binary-extensions": "^1.0.0"
},
"devDependencies": {
"ava": "*"
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ npm install --save is-binary-path
## Usage

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

isBinaryPath('src/unicorn.png');
//=> true
Expand All @@ -25,10 +25,10 @@ isBinaryPath('src/unicorn.txt');

## 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
- [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


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)

0 comments on commit 0ad27ac

Please sign in to comment.