initial commit

This commit is contained in:
air66
2019-07-24 18:16:32 +01:00
commit 5efebf4ded
8591 changed files with 899103 additions and 0 deletions

29
node_modules/istextorbinary/HISTORY.md generated vendored Normal file
View File

@@ -0,0 +1,29 @@
# History
## 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)
## v2.0.0 2016 May 2
- Converted from CoffeeScript to JavaScript
- Fixed `getEncoding` and `isText` not handling errors correctly
- Right-most extension takes preference, instead of left-most
- Thanks to [Ian Sibner](https://github.com/sibnerian) for [pull request #5](https://github.com/bevry/istextorbinary/pull/5)
- **This has bumped the major** as it changes the output result, which could potentially break some apps, despite the API remaining exactly the same
## v1.0.2 2015 January 16
- Fixed build
- Added test for text files
## v1.0.1 2015 January 16
- Cleaned up thanks to [Shunnosuke Watanabe](https://github.com/shinnn) for [pull request #2](https://github.com/bevry/istextorbinary/pull/2)
## v1.0.0 2013 October 25
- Initial release extracted from [balupton/bal-util](https://github.com/balupton/bal-util/blob/6501d51bc0244fce3781fc0150136f7493099237/src/lib/paths.coffee#L100-L201)

24
node_modules/istextorbinary/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
<!-- LICENSEFILE/ -->
<h1>License</h1>
Unless stated otherwise all works are:
<ul><li>Copyright &copy; 2012+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
<li>Copyright &copy; 2011 <a href="http://balupton.com">Benjamin Lupton</a></li></ul>
and licensed under:
<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>
<h2>MIT License</h2>
<pre>
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>
<!-- /LICENSEFILE -->

152
node_modules/istextorbinary/README.md generated vendored Normal file
View File

@@ -0,0 +1,152 @@
<!-- TITLE/ -->
<h1>Is Text or Binary?</h1>
<!-- /TITLE -->
<!-- BADGES/ -->
<span class="badge-travisci"><a href="http://travis-ci.org/bevry/istextorbinary" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/bevry/istextorbinary/master.svg" alt="Travis CI Build Status" /></a></span>
<span class="badge-npmversion"><a href="https://npmjs.org/package/istextorbinary" title="View this project on NPM"><img src="https://img.shields.io/npm/v/istextorbinary.svg" alt="NPM version" /></a></span>
<span class="badge-npmdownloads"><a href="https://npmjs.org/package/istextorbinary" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/istextorbinary.svg" alt="NPM downloads" /></a></span>
<span class="badge-daviddm"><a href="https://david-dm.org/bevry/istextorbinary" title="View the status of this project's dependencies on DavidDM"><img src="https://img.shields.io/david/bevry/istextorbinary.svg" alt="Dependency Status" /></a></span>
<span class="badge-daviddmdev"><a href="https://david-dm.org/bevry/istextorbinary#info=devDependencies" title="View the status of this project's development dependencies on DavidDM"><img src="https://img.shields.io/david/dev/bevry/istextorbinary.svg" alt="Dev Dependency Status" /></a></span>
<br class="badge-separator" />
<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>
<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-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin 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>
<!-- /BADGES -->
<!-- DESCRIPTION/ -->
Determines if a buffer is comprised of text or binary
<!-- /DESCRIPTION -->
<!-- INSTALL/ -->
<h2>Install</h2>
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>NPM</h3></a><ul>
<li>Install: <code>npm install --save istextorbinary</code></li>
<li>Module: <code>require('istextorbinary')</code></li></ul>
<a href="http://browserify.org" title="Browserify lets you require('modules') in the browser by bundling up all of your dependencies"><h3>Browserify</h3></a><ul>
<li>Install: <code>npm install --save istextorbinary</code></li>
<li>Module: <code>require('istextorbinary')</code></li>
<li>CDN URL: <code>//wzrd.in/bundle/istextorbinary@2.2.1</code></li></ul>
<a href="http://enderjs.com" title="Ender is a full featured package manager for your browser"><h3>Ender</h3></a><ul>
<li>Install: <code>ender add istextorbinary</code></li>
<li>Module: <code>require('istextorbinary')</code></li></ul>
<h3><a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
<p>This package is published with the following editions:</p>
<ul><li><code>istextorbinary</code> aliases <code>istextorbinary/index.js</code> which uses <a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li>
<li><code>istextorbinary/source/index.js</code> is Source + <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li>
<li><code>istextorbinary/es2015/index.js</code> is <a href="https://babeljs.io" title="The compiler for writing next generation JavaScript">Babel</a> Compiled + <a href="http://babeljs.io/docs/plugins/preset-es2015/" title="ECMAScript 2015">ES2015</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li></ul>
<p>Older environments may need <a href="https://babeljs.io/docs/usage/polyfill/" title="A polyfill that emulates missing ECMAScript environment features">Babel's Polyfill</a> or something similar.</p>
<!-- /INSTALL -->
## Usage
``` javascript
// Synchronous API
var result = require('istextorbinary').isTextSync(filename, buffer)
// Asynchronous API
require('istextorbinary').isText(filename, buffer, function(err, result){
// ...
})
// You can supply text or buffer, or both text and buffer, the more provided, the more accurate the result
```
[API Documentation.](http://master.istextorbinary.bevry.surge.sh/docs/)
<!-- HISTORY/ -->
<h2>History</h2>
<a href="https://github.com/bevry/istextorbinary/blob/master/HISTORY.md#files">Discover the release history by heading on over to the <code>HISTORY.md</code> file.</a>
<!-- /HISTORY -->
<!-- CONTRIBUTE/ -->
<h2>Contribute</h2>
<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>
<!-- /CONTRIBUTE -->
<!-- BACKERS/ -->
<h2>Backers</h2>
<h3>Maintainers</h3>
These amazing people are maintaining this project:
<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>
<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>
<h3>Sponsors</h3>
No sponsors yet! Will you be the first?
<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>
<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-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin 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>
<h3>Contributors</h3>
These amazing people have contributed code to this project:
<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>
<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>
<!-- /BACKERS -->
<!-- LICENSE/ -->
<h2>License</h2>
Unless stated otherwise all works are:
<ul><li>Copyright &copy; 2012+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
<li>Copyright &copy; 2011 <a href="http://balupton.com">Benjamin Lupton</a></li></ul>
and licensed under:
<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>
<!-- /LICENSE -->

197
node_modules/istextorbinary/es2015/index.js generated vendored Normal file
View File

@@ -0,0 +1,197 @@
/* eslint no-use-before-define:0 */
'use strict';
// Import
var pathUtil = require('path');
var textExtensions = require('textextensions');
var binaryExtensions = require('binaryextensions');
/**
* Is Text (Synchronous)
* Determine whether or not a file is a text or binary file.
* Determined by extension checks first, then if unknown extension, will fallback on encoding detection.
* We do that as encoding detection cannot guarantee everything, especially for chars between utf8 and utf16
* @param {?string} filename - the filename for the file/buffer if available
* @param {?Buffer} buffer - the buffer for the file if available
* @returns {Error|boolean}
*/
function isTextSync(filename, buffer) {
// Prepare
var isText = null;
// Test extensions
if (filename) {
// Extract filename
var parts = pathUtil.basename(filename).split('.').reverse();
// Cycle extensions
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var extension = _step.value;
if (textExtensions.indexOf(extension) !== -1) {
isText = true;
break;
}
if (binaryExtensions.indexOf(extension) !== -1) {
isText = false;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
// Fallback to encoding if extension check was not enough
if (buffer && isText === null) {
isText = getEncodingSync(buffer) === 'utf8';
}
// Return our result
return isText;
}
/**
* Is Text
* Uses `isTextSync` behind the scenes.
* @param {?string} filename - forwarded to `isTextSync`
* @param {?Buffer} buffer - forwarded to `isTextSync`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function isText(filename, buffer, next) {
var result = isTextSync(filename, buffer);
if (result instanceof Error) {
next(result);
} else {
next(null, result);
}
}
/**
* Is Binary (Synchronous)
* Uses `isTextSync` behind the scenes.
* @param {?string} filename - forwarded to `isTextSync`
* @param {?Buffer} buffer - forwarded to `isTextSync`
* @returns {Error|boolean}
*/
function isBinarySync(filename, buffer) {
// Handle
var result = isTextSync(filename, buffer);
return result instanceof Error ? result : !result;
}
/**
* Is Binary
* Uses `isText` behind the scenes.
* @param {?string} filename - forwarded to `isText`
* @param {?Buffer} buffer - forwarded to `isText`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function isBinary(filename, buffer, next) {
// Handle
isText(filename, buffer, function (err, result) {
if (err) return next(err);
return next(null, !result);
});
}
/**
* Get the encoding of a buffer.
* We fetch a bunch chars from the start, middle and end of the buffer.
* We check all three, as doing only start was not enough, and doing only middle was not enough, so better safe than sorry.
* @param {Buffer} buffer
* @param {?Object} [opts]
* @param {?number} [opts.chunkLength = 24]
* @param {?number} [opts.chunkBegin = 0]
* @returns {Error|string} either an Error instance if something went wrong, or if successful "utf8" or "binary"
*/
function getEncodingSync(buffer, opts) {
// Prepare
var textEncoding = 'utf8';
var binaryEncoding = 'binary';
// Discover
if (opts == null) {
// Start
var chunkLength = 24;
var encoding = getEncodingSync(buffer, { chunkLength: chunkLength });
if (encoding === textEncoding) {
// Middle
var chunkBegin = Math.max(0, Math.floor(buffer.length / 2) - chunkLength);
encoding = getEncodingSync(buffer, { chunkLength: chunkLength, chunkBegin: chunkBegin });
if (encoding === textEncoding) {
// End
chunkBegin = Math.max(0, buffer.length - chunkLength);
encoding = getEncodingSync(buffer, { chunkLength: chunkLength, chunkBegin: chunkBegin });
}
}
// Return
return encoding;
} else {
// Extract
var _opts$chunkLength = opts.chunkLength,
_chunkLength = _opts$chunkLength === undefined ? 24 : _opts$chunkLength,
_opts$chunkBegin = opts.chunkBegin,
_chunkBegin = _opts$chunkBegin === undefined ? 0 : _opts$chunkBegin;
var chunkEnd = Math.min(buffer.length, _chunkBegin + _chunkLength);
var contentChunkUTF8 = buffer.toString(textEncoding, _chunkBegin, chunkEnd);
var _encoding = textEncoding;
// Detect encoding
for (var i = 0; i < contentChunkUTF8.length; ++i) {
var charCode = contentChunkUTF8.charCodeAt(i);
if (charCode === 65533 || charCode <= 8) {
// 8 and below are control characters (e.g. backspace, null, eof, etc.)
// 65533 is the unknown character
// console.log(charCode, contentChunkUTF8[i])
_encoding = binaryEncoding;
break;
}
}
// Return
return _encoding;
}
}
/**
* Get the encoding of a buffer
* Uses `getEncodingSync` behind the scenes.
* @param {Buffer} buffer - forwarded to `getEncodingSync`
* @param {Object} opts - forwarded to `getEncodingSync`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function getEncoding(buffer, opts, next) {
// Fetch and wrap result
var result = getEncodingSync(buffer, opts);
if (result instanceof Error) {
next(result);
} else {
next(null, result);
}
}
// Export
module.exports = { isTextSync: isTextSync, isText: isText, isBinarySync: isBinarySync, isBinary: isBinary, getEncodingSync: getEncodingSync, getEncoding: getEncoding };

5
node_modules/istextorbinary/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// 2016 December 29
// https://github.com/bevry/editions
'use strict'
module.exports = require('editions').requirePackage(__dirname, require)

197
node_modules/istextorbinary/package.json generated vendored Normal file
View File

@@ -0,0 +1,197 @@
{
"_from": "istextorbinary@2.2.1",
"_id": "istextorbinary@2.2.1",
"_inBundle": false,
"_integrity": "sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==",
"_location": "/istextorbinary",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "istextorbinary@2.2.1",
"name": "istextorbinary",
"escapedName": "istextorbinary",
"rawSpec": "2.2.1",
"saveSpec": null,
"fetchSpec": "2.2.1"
},
"_requiredBy": [
"/gulp-replace"
],
"_resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz",
"_shasum": "a5231a08ef6dd22b268d0895084cf8d58b5bec53",
"_spec": "istextorbinary@2.2.1",
"_where": "D:\\Air66 Files\\dev_sites\\www.airurl.dev.cc\\user\\plugins\\air66Theme\\node_modules\\gulp-replace",
"author": {
"name": "2012+ Bevry Pty Ltd",
"email": "us@bevry.me",
"url": "http://bevry.me"
},
"badges": {
"list": [
"travisci",
"npmversion",
"npmdownloads",
"daviddm",
"daviddmdev",
"---",
"patreon",
"opencollective",
"gratipay",
"flattr",
"paypal",
"bitcoin",
"wishlist",
"---",
"slackin"
],
"config": {
"patreonUsername": "bevry",
"opencollectiveUsername": "bevry",
"gratipayUsername": "bevry",
"flattrUsername": "balupton",
"paypalURL": "https://bevry.me/paypal",
"bitcoinURL": "https://bevry.me/bitcoin",
"wishlistURL": "https://bevry.me/wishlist",
"slackinURL": "https://slack.bevry.me"
}
},
"browser": "es2015/index.js",
"bugs": {
"url": "https://github.com/bevry/istextorbinary/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"url": "http://balupton.com"
},
{
"name": "Shinnosuke Watanabe",
"email": "snnskwtnb@gmail.com",
"url": "http://shinnn.github.io"
},
{
"name": "Ian Sibner",
"email": "sibnerian@gmail.com",
"url": "http://www.sibnerian.com/"
},
{
"name": "Sean",
"email": "albinodrought@gmail.com",
"url": "https://github.com/AlbinoDrought"
}
],
"dependencies": {
"binaryextensions": "2",
"editions": "^1.3.3",
"textextensions": "2"
},
"deprecated": false,
"description": "Determines if a buffer is comprised of text or binary",
"devDependencies": {
"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"
},
"editions": [
{
"description": "Source + ESNext + Require",
"entry": "index.js",
"directory": "source",
"syntaxes": [
"javascript",
"esnext",
"require",
"const",
"let",
"forof",
"destructuring",
"defaults"
]
},
{
"description": "Babel Compiled + ES2015 + Require",
"entry": "index.js",
"directory": "es2015",
"syntaxes": [
"javascript",
"es2015",
"require"
]
}
],
"engines": {
"node": ">=0.12"
},
"homepage": "https://github.com/bevry/istextorbinary",
"keywords": [
"text",
"binary",
"encoding",
"istext",
"is text",
"isbinary",
"is binary",
"is text or binary",
"is text or binary file",
"isbinaryfile",
"is binary file",
"istextfile",
"is text file"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"url": "http://balupton.com"
},
{
"name": "Rob Loach",
"email": "robloach@gmail.com",
"url": "https://github.com/robloach"
},
{
"name": "Michael Mooring",
"email": "mike@mdm.cc",
"url": "https://github.com/mikeumus"
}
],
"name": "istextorbinary",
"repository": {
"type": "git",
"url": "git+https://github.com/bevry/istextorbinary.git"
},
"scripts": {
"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:release": "npm run our:release:prepare && npm run our:release:check && npm run our:release:tag && npm run our:release:push",
"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:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta",
"our:release:push": "git push origin master && git push origin --tags",
"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:setup": "npm run our:setup:npm",
"our:setup:npm": "npm install",
"our:test": "npm run our:verify && npm test",
"our:verify": "npm run our:verify:eslint",
"our:verify:eslint": "eslint --fix ./source",
"test": "node --harmony ./test.js --joe-reporter=console"
},
"title": "Is Text or Binary?",
"version": "2.2.1"
}

174
node_modules/istextorbinary/source/index.js generated vendored Normal file
View File

@@ -0,0 +1,174 @@
/* eslint no-use-before-define:0 */
'use strict'
// Import
const pathUtil = require('path')
const textExtensions = require('textextensions')
const binaryExtensions = require('binaryextensions')
/**
* Is Text (Synchronous)
* Determine whether or not a file is a text or binary file.
* Determined by extension checks first, then if unknown extension, will fallback on encoding detection.
* We do that as encoding detection cannot guarantee everything, especially for chars between utf8 and utf16
* @param {?string} filename - the filename for the file/buffer if available
* @param {?Buffer} buffer - the buffer for the file if available
* @returns {Error|boolean}
*/
function isTextSync (filename, buffer) {
// Prepare
let isText = null
// Test extensions
if (filename) {
// Extract filename
const parts = pathUtil.basename(filename).split('.').reverse()
// Cycle extensions
for (const extension of parts) {
if (textExtensions.indexOf(extension) !== -1) {
isText = true
break
}
if (binaryExtensions.indexOf(extension) !== -1) {
isText = false
break
}
}
}
// Fallback to encoding if extension check was not enough
if (buffer && isText === null) {
isText = getEncodingSync(buffer) === 'utf8'
}
// Return our result
return isText
}
/**
* Is Text
* Uses `isTextSync` behind the scenes.
* @param {?string} filename - forwarded to `isTextSync`
* @param {?Buffer} buffer - forwarded to `isTextSync`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function isText (filename, buffer, next) {
const result = isTextSync(filename, buffer)
if (result instanceof Error) {
next(result)
}
else {
next(null, result)
}
}
/**
* Is Binary (Synchronous)
* Uses `isTextSync` behind the scenes.
* @param {?string} filename - forwarded to `isTextSync`
* @param {?Buffer} buffer - forwarded to `isTextSync`
* @returns {Error|boolean}
*/
function isBinarySync (filename, buffer) {
// Handle
const result = isTextSync(filename, buffer)
return result instanceof Error ? result : !result
}
/**
* Is Binary
* Uses `isText` behind the scenes.
* @param {?string} filename - forwarded to `isText`
* @param {?Buffer} buffer - forwarded to `isText`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function isBinary (filename, buffer, next) {
// Handle
isText(filename, buffer, function (err, result) {
if (err) return next(err)
return next(null, !result)
})
}
/**
* Get the encoding of a buffer.
* We fetch a bunch chars from the start, middle and end of the buffer.
* We check all three, as doing only start was not enough, and doing only middle was not enough, so better safe than sorry.
* @param {Buffer} buffer
* @param {?Object} [opts]
* @param {?number} [opts.chunkLength = 24]
* @param {?number} [opts.chunkBegin = 0]
* @returns {Error|string} either an Error instance if something went wrong, or if successful "utf8" or "binary"
*/
function getEncodingSync (buffer, opts) {
// Prepare
const textEncoding = 'utf8'
const binaryEncoding = 'binary'
// Discover
if (opts == null) {
// Start
const chunkLength = 24
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) {
// End
chunkBegin = Math.max(0, buffer.length - chunkLength)
encoding = getEncodingSync(buffer, { chunkLength, chunkBegin })
}
}
// Return
return encoding
}
else {
// Extract
const { chunkLength = 24, chunkBegin = 0 } = opts
const chunkEnd = Math.min(buffer.length, chunkBegin + chunkLength)
const contentChunkUTF8 = buffer.toString(textEncoding, chunkBegin, chunkEnd)
let encoding = textEncoding
// Detect encoding
for (let i = 0; i < contentChunkUTF8.length; ++i) {
const charCode = contentChunkUTF8.charCodeAt(i)
if (charCode === 65533 || charCode <= 8) {
// 8 and below are control characters (e.g. backspace, null, eof, etc.)
// 65533 is the unknown character
// console.log(charCode, contentChunkUTF8[i])
encoding = binaryEncoding
break
}
}
// Return
return encoding
}
}
/**
* Get the encoding of a buffer
* Uses `getEncodingSync` behind the scenes.
* @param {Buffer} buffer - forwarded to `getEncodingSync`
* @param {Object} opts - forwarded to `getEncodingSync`
* @param {Function} next - accepts arguments: (error: Error, result: Boolean)
* @returns {nothing}
*/
function getEncoding (buffer, opts, next) {
// Fetch and wrap result
const result = getEncodingSync(buffer, opts)
if (result instanceof Error) {
next(result)
}
else {
next(null, result)
}
}
// Export
module.exports = { isTextSync, isText, isBinarySync, isBinary, getEncodingSync, getEncoding }