istextorbinary
Advanced tools
Comparing version 2.1.0 to 2.2.1
@@ -0,6 +1,6 @@ | ||
/* eslint no-use-before-define:0 */ | ||
'use strict'; | ||
/* eslint no-use-before-define:0 */ | ||
// Import | ||
// Import | ||
var pathUtil = require('path'); | ||
@@ -152,10 +152,7 @@ var textExtensions = require('textextensions'); | ||
// Extract | ||
var _opts$chunkLength = opts.chunkLength; | ||
var _opts$chunkLength = opts.chunkLength, | ||
_chunkLength = _opts$chunkLength === undefined ? 24 : _opts$chunkLength, | ||
_opts$chunkBegin = opts.chunkBegin, | ||
_chunkBegin = _opts$chunkBegin === undefined ? 0 : _opts$chunkBegin; | ||
var _chunkLength = _opts$chunkLength === undefined ? 24 : _opts$chunkLength; | ||
var _opts$chunkBegin = opts.chunkBegin; | ||
var _chunkBegin = _opts$chunkBegin === undefined ? 0 : _opts$chunkBegin; | ||
var chunkEnd = Math.min(buffer.length, _chunkBegin + _chunkLength); | ||
@@ -162,0 +159,0 @@ var contentChunkUTF8 = buffer.toString(textEncoding, _chunkBegin, chunkEnd); |
# History | ||
## v2.0.0 2016 May 10 | ||
## v2.2.1 2018 January 24 | ||
- Added missing development dependency | ||
## v2.2.0 2018 January 24 | ||
- Fixed invalid `package.json` error | ||
- Thanks to [Sean](https://github.com/AlbinoDrought) for [pull request #8](https://github.com/bevry/istextorbinary/pull/8) | ||
- Updated base files | ||
## v2.1.0 2016 May 10 | ||
- Support v2 of [textextensions](https://github.com/bevry/textextensions) and [binaryextensions](https://github.com/bevry/binaryextensions) | ||
@@ -5,0 +13,0 @@ |
@@ -1,3 +0,5 @@ | ||
// 2016 March 8 | ||
// 2016 December 29 | ||
// https://github.com/bevry/editions | ||
'use strict' | ||
module.exports = require('editions').requirePackage(__dirname, require) |
@@ -8,3 +8,3 @@ <!-- LICENSEFILE/ --> | ||
<ul><li>Copyright © 2012+ <a href="http://bevry.me">Bevry Pty Ltd</a></li> | ||
<li>Copyright © 2011 <a href="https://balupton.com">Benjamin Lupton</a></li></ul> | ||
<li>Copyright © 2011 <a href="http://balupton.com">Benjamin Lupton</a></li></ul> | ||
@@ -11,0 +11,0 @@ and licensed under: |
100
package.json
{ | ||
"title": "Is Text or Binary?", | ||
"name": "istextorbinary", | ||
"version": "2.1.0", | ||
"version": "2.2.1", | ||
"description": "Determines if a buffer is comprised of text or binary", | ||
@@ -11,3 +11,13 @@ "homepage": "https://github.com/bevry/istextorbinary", | ||
"binary", | ||
"encoding" | ||
"encoding", | ||
"istext", | ||
"is text", | ||
"isbinary", | ||
"is binary", | ||
"is text or binary", | ||
"is text or binary file", | ||
"isbinaryfile", | ||
"is binary file", | ||
"istextfile", | ||
"is text file" | ||
], | ||
@@ -22,4 +32,4 @@ "badges": { | ||
"---", | ||
"slackin", | ||
"patreon", | ||
"opencollective", | ||
"gratipay", | ||
@@ -29,6 +39,9 @@ "flattr", | ||
"bitcoin", | ||
"wishlist" | ||
"wishlist", | ||
"---", | ||
"slackin" | ||
], | ||
"config": { | ||
"patreonUsername": "bevry", | ||
"opencollectiveUsername": "bevry", | ||
"gratipayUsername": "bevry", | ||
@@ -42,5 +55,5 @@ "flattrUsername": "balupton", | ||
}, | ||
"author": "2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011 Benjamin Lupton <b@lupton.cc> (https://balupton.com)", | ||
"author": "2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)", | ||
"maintainers": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)", | ||
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)", | ||
"Rob Loach <robloach@gmail.com> (https://github.com/robloach)", | ||
@@ -50,5 +63,6 @@ "Michael Mooring <mike@mdm.cc> (https://github.com/mikeumus)" | ||
"contributors": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)", | ||
"shinnn <snnskwtnb@gmail.com> (https://shinnn.github.io)", | ||
"Ian Sibner <sibnerian@gmail.com> (https://github.com/sibnerian)" | ||
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)", | ||
"Shinnosuke Watanabe <snnskwtnb@gmail.com> (http://shinnn.github.io)", | ||
"Ian Sibner <sibnerian@gmail.com> (http://www.sibnerian.com/)", | ||
"Sean <albinodrought@gmail.com> (https://github.com/AlbinoDrought)" | ||
], | ||
@@ -60,3 +74,3 @@ "bugs": { | ||
"type": "git", | ||
"url": "http://github.com/bevry/istextorbinary.git" | ||
"url": "https://github.com/bevry/istextorbinary.git" | ||
}, | ||
@@ -69,3 +83,3 @@ "engines": { | ||
"description": "Source + ESNext + Require", | ||
"entry": "source/index.js", | ||
"entry": "index.js", | ||
"directory": "source", | ||
@@ -85,3 +99,3 @@ "syntaxes": [ | ||
"description": "Babel Compiled + ES2015 + Require", | ||
"entry": "es2015/index.js", | ||
"entry": "index.js", | ||
"directory": "es2015", | ||
@@ -97,35 +111,39 @@ "syntaxes": [ | ||
"browser": "es2015/index.js", | ||
"scripts": { | ||
"setup": "npm install", | ||
"clean": "rm -Rf ./docs ./es2015", | ||
"compile": "npm run compile:es2015", | ||
"compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015", | ||
"meta": "npm run meta:docs && npm run meta:projectz", | ||
"meta:docs": "documentation build -f html -g --shallow ./source/**.js -o ./docs", | ||
"meta:projectz": "projectz compile", | ||
"prepare": "npm run compile && npm run test && npm run meta", | ||
"release": "npm run prepare && npm run release:publish && npm run release:tag && npm run release:push", | ||
"release:publish": "npm publish", | ||
"release:tag": "git tag v$npm_package_version -a", | ||
"release:push": "git push origin master && git push origin --tags", | ||
"pretest": "npm run test:eslint", | ||
"test:eslint": "eslint ./source", | ||
"test": "node --harmony -e \"require('editions').requirePackage(process.cwd(), require, 'test.js')\"" | ||
}, | ||
"dependencies": { | ||
"textextensions": "1 || 2", | ||
"binaryextensions": "1 || 2", | ||
"editions": "^1.1.1" | ||
"binaryextensions": "2", | ||
"editions": "^1.3.3", | ||
"textextensions": "2" | ||
}, | ||
"devDependencies": { | ||
"assert-helpers": "^4.2.0", | ||
"babel-cli": "^6.8.0", | ||
"babel-preset-es2015": "^6.6.0", | ||
"documentation": "^4.0.0-beta2", | ||
"eslint": "^2.9.0", | ||
"eslint-plugin-babel": "^3.2.0", | ||
"joe": "^1.6.0", | ||
"joe-reporter-console": "^1.2.1", | ||
"projectz": "^1.1.5" | ||
"assert-helpers": "^4.5.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"documentation": "^5.3.5", | ||
"eslint": "^4.16.0", | ||
"joe": "^2.0.2", | ||
"joe-reporter-console": "^2.0.1", | ||
"projectz": "^1.4.0", | ||
"surge": "^0.19.0" | ||
}, | ||
"scripts": { | ||
"our:setup": "npm run our:setup:npm", | ||
"our:setup:npm": "npm install", | ||
"our:clean": "rm -Rf ./docs ./es2015 ./es5 ./out", | ||
"our:compile": "npm run our:compile:es2015", | ||
"our:compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015", | ||
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz", | ||
"our:meta:docs": "documentation build -f html -o ./docs -g --shallow ./source/**.js", | ||
"our:meta:projectz": "projectz compile", | ||
"our:verify": "npm run our:verify:eslint", | ||
"our:verify:eslint": "eslint --fix ./source", | ||
"our:test": "npm run our:verify && npm test", | ||
"our:release": "npm run our:release:prepare && npm run our:release:check && npm run our:release:tag && npm run our:release:push", | ||
"our:release:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta", | ||
"our:release:check": "npm run our:release:check:changelog && npm run our:release:check:dirty", | ||
"our:release:check:changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)", | ||
"our:release:check:dirty": "git diff --exit-code", | ||
"our:release:tag": "export MESSAGE=$(cat ./HISTORY.md | sed -n \"/## v$npm_package_version/,/##/p\" | sed 's/## //' | awk 'NR>1{print buf}{buf = $0}') && test \"$MESSAGE\" || (echo 'proper changelog entry not found' && exit -1) && git tag v$npm_package_version -am \"$MESSAGE\"", | ||
"our:release:push": "git push origin master && git push origin --tags", | ||
"test": "node --harmony ./test.js --joe-reporter=console" | ||
} | ||
} |
@@ -16,4 +16,4 @@ <!-- TITLE/ --> | ||
<br class="badge-separator" /> | ||
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span> | ||
<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span> | ||
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span> | ||
@@ -24,2 +24,4 @@ <span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span> | ||
<br class="badge-separator" /> | ||
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span> | ||
@@ -47,3 +49,3 @@ <!-- /BADGES --> | ||
<li>Module: <code>require('istextorbinary')</code></li> | ||
<li>CDN URL: <code>//wzrd.in/bundle/istextorbinary@2.1.0</code></li></ul> | ||
<li>CDN URL: <code>//wzrd.in/bundle/istextorbinary@2.2.1</code></li></ul> | ||
@@ -81,3 +83,3 @@ <a href="http://enderjs.com" title="Ender is a full featured package manager for your browser"><h3>Ender</h3></a><ul> | ||
[API Documentation.](http://rawgit.com/bevry/istextorbinary/master/docs/index.html) | ||
[API Documentation.](http://master.istextorbinary.bevry.surge.sh/docs/) | ||
@@ -111,3 +113,3 @@ | ||
<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/istextorbinary">view contributions</a></li> | ||
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li> | ||
<li><a href="https://github.com/robloach">Rob Loach</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=robloach" title="View the GitHub contributions of Rob Loach on repository bevry/istextorbinary">view contributions</a></li> | ||
@@ -120,3 +122,4 @@ <li><a href="https://github.com/mikeumus">Michael Mooring</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=mikeumus" title="View the GitHub contributions of Michael Mooring on repository bevry/istextorbinary">view contributions</a></li></ul> | ||
<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span> | ||
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span> | ||
@@ -132,5 +135,6 @@ <span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/istextorbinary">view contributions</a></li> | ||
<li><a href="https://shinnn.github.io">shinnn</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=shinnn" title="View the GitHub contributions of shinnn on repository bevry/istextorbinary">view contributions</a></li> | ||
<li><a href="https://github.com/sibnerian">Ian Sibner</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=sibnerian" title="View the GitHub contributions of Ian Sibner on repository bevry/istextorbinary">view contributions</a></li></ul> | ||
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li> | ||
<li><a href="http://shinnn.github.io">Shinnosuke Watanabe</a></li> | ||
<li><a href="http://www.sibnerian.com/">Ian Sibner</a></li> | ||
<li><a href="https://github.com/AlbinoDrought">Sean</a> — <a href="https://github.com/bevry/istextorbinary/commits?author=AlbinoDrought" title="View the GitHub contributions of Sean on repository bevry/istextorbinary">view contributions</a></li></ul> | ||
@@ -149,3 +153,3 @@ <a href="https://github.com/bevry/istextorbinary/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a> | ||
<ul><li>Copyright © 2012+ <a href="http://bevry.me">Bevry Pty Ltd</a></li> | ||
<li>Copyright © 2011 <a href="https://balupton.com">Benjamin Lupton</a></li></ul> | ||
<li>Copyright © 2011 <a href="http://balupton.com">Benjamin Lupton</a></li></ul> | ||
@@ -152,0 +156,0 @@ and licensed under: |
/* eslint no-use-before-define:0 */ | ||
'use strict' | ||
@@ -22,3 +23,3 @@ // Import | ||
// Test extensions | ||
if ( filename ) { | ||
if (filename) { | ||
// Extract filename | ||
@@ -28,8 +29,8 @@ const parts = pathUtil.basename(filename).split('.').reverse() | ||
// Cycle extensions | ||
for ( const extension of parts ) { | ||
if ( textExtensions.indexOf(extension) !== -1 ) { | ||
for (const extension of parts) { | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
isText = true | ||
break | ||
} | ||
if ( binaryExtensions.indexOf(extension) !== -1 ) { | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
isText = false | ||
@@ -42,3 +43,3 @@ break | ||
// Fallback to encoding if extension check was not enough | ||
if ( buffer && isText === null ) { | ||
if (buffer && isText === null) { | ||
isText = getEncodingSync(buffer) === 'utf8' | ||
@@ -61,3 +62,3 @@ } | ||
const result = isTextSync(filename, buffer) | ||
if ( result instanceof Error ) { | ||
if (result instanceof Error) { | ||
next(result) | ||
@@ -94,3 +95,3 @@ } | ||
isText(filename, buffer, function (err, result) { | ||
if ( err ) return next(err) | ||
if (err) return next(err) | ||
return next(null, !result) | ||
@@ -116,14 +117,14 @@ }) | ||
// Discover | ||
if ( opts == null ) { | ||
if (opts == null) { | ||
// Start | ||
const chunkLength = 24 | ||
let encoding = getEncodingSync(buffer, {chunkLength}) | ||
if ( encoding === textEncoding ) { | ||
let encoding = getEncodingSync(buffer, { chunkLength }) | ||
if (encoding === textEncoding) { | ||
// Middle | ||
let chunkBegin = Math.max(0, Math.floor(buffer.length / 2) - chunkLength) | ||
encoding = getEncodingSync(buffer, {chunkLength, chunkBegin}) | ||
if ( encoding === textEncoding ) { | ||
encoding = getEncodingSync(buffer, { chunkLength, chunkBegin }) | ||
if (encoding === textEncoding) { | ||
// End | ||
chunkBegin = Math.max(0, buffer.length - chunkLength) | ||
encoding = getEncodingSync(buffer, {chunkLength, chunkBegin}) | ||
encoding = getEncodingSync(buffer, { chunkLength, chunkBegin }) | ||
} | ||
@@ -137,3 +138,3 @@ } | ||
// Extract | ||
const {chunkLength = 24, chunkBegin = 0} = opts | ||
const { chunkLength = 24, chunkBegin = 0 } = opts | ||
const chunkEnd = Math.min(buffer.length, chunkBegin + chunkLength) | ||
@@ -144,5 +145,5 @@ const contentChunkUTF8 = buffer.toString(textEncoding, chunkBegin, chunkEnd) | ||
// Detect encoding | ||
for ( let i = 0; i < contentChunkUTF8.length; ++i ) { | ||
for (let i = 0; i < contentChunkUTF8.length; ++i) { | ||
const charCode = contentChunkUTF8.charCodeAt(i) | ||
if ( charCode === 65533 || charCode <= 8 ) { | ||
if (charCode === 65533 || charCode <= 8) { | ||
// 8 and below are control characters (e.g. backspace, null, eof, etc.) | ||
@@ -172,3 +173,3 @@ // 65533 is the unknown character | ||
const result = getEncodingSync(buffer, opts) | ||
if ( result instanceof Error ) { | ||
if (result instanceof Error) { | ||
next(result) | ||
@@ -182,2 +183,2 @@ } | ||
// Export | ||
module.exports = {isTextSync, isText, isBinarySync, isBinary, getEncodingSync, getEncoding} | ||
module.exports = { isTextSync, isText, isBinarySync, isBinary, getEncodingSync, getEncoding } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
153
28123
7
338
2
Updatedbinaryextensions@2
Updatededitions@^1.3.3
Updatedtextextensions@2