istextorbinary
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -71,7 +71,7 @@ // @ts-check | ||
if (textExtensions.includes(extension)) { | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
return true; | ||
} | ||
if (binaryExtensions.includes(extension)) { | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
return false; | ||
@@ -78,0 +78,0 @@ } |
@@ -71,7 +71,7 @@ // @ts-check | ||
if (textExtensions.includes(extension)) { | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
return true; | ||
} | ||
if (binaryExtensions.includes(extension)) { | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
return false; | ||
@@ -78,0 +78,0 @@ } |
# History | ||
## v2.5.1 2019 January 21 | ||
- Fixed a readme documentation inconsistency | ||
- Fixed node v0.12 and v4 support (regression since v2.5.0) | ||
## v2.5.0 2019 January 21 | ||
@@ -84,2 +90,2 @@ | ||
- Initial release extracted from [balupton/bal-util](https://github.com/balupton/bal-util/blob/6501d51bc0244fce3781fc0150136f7493099237/src/lib/paths.coffee#L100-L201) where it was introduced [2012 September 24](https://github.com/balupton/bal-util/blob/master/HISTORY.md#v1137-2012-september-24). | ||
- Initial release [extracted](https://github.com/balupton/bal-util/blob/6501d51bc0244fce3781fc0150136f7493099237/src/lib/paths.coffee#L100-L201) from [bal-util](https://npmjs.com/package/bal-util) where it was introduced [2012 September 24](https://github.com/balupton/bal-util/blob/master/HISTORY.md#v1137-2012-september-24). |
{ | ||
"title": "Is Text or Binary?", | ||
"name": "istextorbinary", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/bevry/istextorbinary", |
@@ -40,5 +40,5 @@ <!-- TITLE/ --> | ||
1. Extension Check: If filename is available, check if any of its extensions (from right to left) are an [text extension](https://github.com/bevry/textextensions) or a [binary extension](https://github.com/bevry/binaryextensions), this is near instant. | ||
2. Buffer Check: If no filename was provided, or the extension check was indeterminate, then check the buffer. | ||
2. Contents Check: If no filename was provided, or the extension check was indeterminate, then check the contents of the buffer. | ||
The extension check will check each of the filenames extensions, from right to left. This is done, as certain applications utilise multiple extensions for transformations, such as `app.x.y` may tell a compiler to transform from `x` format to `y` format, if `x` is not a recognized extension but `y` is a recognized extension, then we can make use of that, to provide accuracy and convenience. | ||
The extension check will check each of the filename's extensions, from right to left. This is done as certain applications utilise multiple extensions for transformations, such as `app.x.y` may tell a compiler to transform from `x` format to `y` format, in this case perhaps `x` is not a recognized extension but `y` is, in which case we can make use of that to provide superior accuracy and convenience compared to just checking the rightmost extension. | ||
@@ -45,0 +45,0 @@ The contents check (with the default options) will check 24 bytes at the start, middle, and end of the buffer. History has shown that checking all three locations is mandatory for accuracy, and that anything less is not accurate. This technique offers superior performance while still offering superior accuracy. Alternatives generally just do 1000 bytes at the start, which is slower, and inaccurate. |
@@ -65,6 +65,6 @@ // @ts-check | ||
for (const extension of parts) { | ||
if (textExtensions.includes(extension)) { | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
return true | ||
} | ||
if (binaryExtensions.includes(extension)) { | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
return false | ||
@@ -71,0 +71,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56241