is-text-path
Advanced tools
Comparing version 1.0.1 to 2.0.0
13
index.js
'use strict'; | ||
var path = require('path'); | ||
var textExtensions = require('text-extensions'); | ||
var exts = Object.create(null); | ||
const path = require('path'); | ||
const textExtensions = require('text-extensions'); | ||
textExtensions.forEach(function (el) { | ||
exts[el] = true; | ||
}); | ||
const extensions = new Set(textExtensions); | ||
module.exports = function (filepath) { | ||
return path.extname(filepath).slice(1).toLowerCase() in exts; | ||
}; | ||
module.exports = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase()); |
{ | ||
"name": "is-text-path", | ||
"version": "1.0.1", | ||
"description": "Check if a filepath is a text file", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-text-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"txt", | ||
"text", | ||
"ext", | ||
"extensions", | ||
"extension", | ||
"file", | ||
"path", | ||
"check", | ||
"detect", | ||
"is" | ||
], | ||
"dependencies": { | ||
"text-extensions": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
} | ||
"name": "is-text-path", | ||
"version": "2.0.0", | ||
"description": "Check if a file path is a text file", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-text-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"text", | ||
"extensions", | ||
"extension", | ||
"file", | ||
"path", | ||
"check", | ||
"detect", | ||
"is" | ||
], | ||
"dependencies": { | ||
"text-extensions": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
# is-text-path [![Build Status](https://travis-ci.org/sindresorhus/is-text-path.svg?branch=master)](https://travis-ci.org/sindresorhus/is-text-path) | ||
> Check if a filepath is a text file | ||
> Check if a file path is a text file | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save is-text-path | ||
$ npm install is-text-path | ||
``` | ||
@@ -17,8 +17,8 @@ | ||
```js | ||
var isTextPath = require('is-text-path'); | ||
const isTextPath = require('is-text-path'); | ||
isTextPath('src/unicorn.txt'); | ||
isTextPath('source/unicorn.txt'); | ||
//=> true | ||
isTextPath('src/unicorn.png'); | ||
isTextPath('source/unicorn.png'); | ||
//=> false | ||
@@ -31,3 +31,3 @@ ``` | ||
- [`text-extensions`](https://github.com/sindresorhus/text-extensions) - List of text file extensions | ||
- [`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 | ||
@@ -37,2 +37,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2947
5
18
0
3
+ Addedtext-extensions@2.4.0(transitive)
- Removedtext-extensions@1.9.0(transitive)
Updatedtext-extensions@^2.0.0