istextorbinary
Advanced tools
Comparing version 4.3.0 to 5.0.0-next.1590821539.444b08db17a7f4c6dd041d6f3d05c4e7d7fbbf5f
@@ -1,112 +0,7 @@ | ||
// @ts-check | ||
/* eslint no-use-before-define:0 */ | ||
'use strict' // Import | ||
function _createForOfIteratorHelper(o) { | ||
if (typeof Symbol === 'undefined' || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { | ||
var i = 0 | ||
var F = function F() {} | ||
return { | ||
s: F, | ||
n: function n() { | ||
if (i >= o.length) return { done: true } | ||
return { done: false, value: o[i++] } | ||
}, | ||
e: function e(_e) { | ||
throw _e | ||
}, | ||
f: F, | ||
} | ||
} | ||
throw new TypeError( | ||
'Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' | ||
) | ||
} | ||
var it, | ||
normalCompletion = true, | ||
didErr = false, | ||
err | ||
return { | ||
s: function s() { | ||
it = o[Symbol.iterator]() | ||
}, | ||
n: function n() { | ||
var step = it.next() | ||
normalCompletion = step.done | ||
return step | ||
}, | ||
e: function e(_e2) { | ||
didErr = true | ||
err = _e2 | ||
}, | ||
f: function f() { | ||
try { | ||
if (!normalCompletion && it.return != null) it.return() | ||
} finally { | ||
if (didErr) throw err | ||
} | ||
}, | ||
} | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return | ||
if (typeof o === 'string') return _arrayLikeToArray(o, minLen) | ||
var n = Object.prototype.toString.call(o).slice(8, -1) | ||
if (n === 'Object' && o.constructor) n = o.constructor.name | ||
if (n === 'Map' || n === 'Set') return Array.from(o) | ||
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) | ||
return _arrayLikeToArray(o, minLen) | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) { | ||
arr2[i] = arr[i] | ||
} | ||
return arr2 | ||
} | ||
var pathUtil = require('path') | ||
var textExtensions = require('textextensions') | ||
var binaryExtensions = require('binaryextensions') | ||
// Import | ||
import pathUtil from 'path' | ||
import textExtensions from 'textextensions' | ||
import binaryExtensions from 'binaryextensions' | ||
/** | ||
* Will be `null` if `buffer` was not provided. Otherwise will be either `'utf8'` or `'binary'`. | ||
* @typedef {'utf8'|'binary'|null} EncodingResult | ||
*/ | ||
/** | ||
* Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result. | ||
* @typedef {boolean|null} TextOrBinaryResult | ||
*/ | ||
/** | ||
* @typedef {Object} EncodingOpts | ||
* @property {number} [chunkLength = 24] | ||
* @property {number} [chunkBegin = 0] | ||
*/ | ||
/** | ||
* @callback IsTextCallback | ||
* @param {Error?} error | ||
* @param {TextOrBinaryResult} [isTextResult] | ||
*/ | ||
/** | ||
* @callback IsBinaryCallback | ||
* @param {Error?} error | ||
* @param {TextOrBinaryResult} [isBinaryResult] | ||
*/ | ||
/** | ||
* @callback GetEncodingCallback | ||
* @param {Error?} error | ||
* @param {EncodingResult} [encoding] | ||
*/ | ||
/** | ||
* Determine if the filename and/or buffer is text. | ||
@@ -116,99 +11,39 @@ * Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection. | ||
* The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions | ||
* In a later major release, this function will become {@link isText} so you should use that instead. | ||
* @param {string} [filename] The filename for the file/buffer if available | ||
* @param {Buffer} [buffer] The buffer for the file if available | ||
* @returns {TextOrBinaryResult} | ||
* @param filename The filename for the file/buffer if available | ||
* @param buffer The buffer for the file if available | ||
* @returns Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result. | ||
*/ | ||
function isTextSync(filename, buffer) { | ||
export function isText(filename, buffer) { | ||
// Test extensions | ||
if (filename) { | ||
// Extract filename | ||
var parts = pathUtil.basename(filename).split('.').reverse() // Cycle extensions | ||
var _iterator = _createForOfIteratorHelper(parts), | ||
_step | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done; ) { | ||
var extension = _step.value | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
return true | ||
} | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
return false | ||
} | ||
const parts = pathUtil.basename(filename).split('.').reverse() | ||
// Cycle extensions | ||
for (const extension of parts) { | ||
if (textExtensions.indexOf(extension) !== -1) { | ||
return true | ||
} | ||
} catch (err) { | ||
_iterator.e(err) | ||
} finally { | ||
_iterator.f() | ||
if (binaryExtensions.indexOf(extension) !== -1) { | ||
return false | ||
} | ||
} | ||
} // Fallback to encoding if extension check was not enough | ||
} | ||
// Fallback to encoding if extension check was not enough | ||
if (buffer) { | ||
return getEncodingSync(buffer) === 'utf8' | ||
} // No buffer was provided | ||
return getEncoding(buffer) === 'utf8' | ||
} | ||
// No buffer was provided | ||
return null | ||
} | ||
/** | ||
* Callback wrapper for {@link isTextSync}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @param {IsTextCallback} callback | ||
* @returns {void} | ||
* Determine if the filename and/or buffer is binary. | ||
* Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection. | ||
* This order is done, as extension checks are quicker, and also because encoding checks cannot guarantee accuracy for chars between utf8 and utf16. | ||
* The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions | ||
* @param filename The filename for the file/buffer if available | ||
* @param buffer The buffer for the file if available | ||
* @returns Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result. | ||
*/ | ||
function isTextCallback(filename, buffer, callback) { | ||
var result | ||
try { | ||
result = isTextSync(filename, buffer) | ||
} catch (err) { | ||
callback(err) | ||
} | ||
callback(null, result) | ||
} | ||
/** | ||
* Promise wrapper for {@link isTextSync}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @returns {Promise<TextOrBinaryResult>} | ||
*/ | ||
function isTextPromise(filename, buffer) { | ||
try { | ||
return Promise.resolve(isTextSync(filename, buffer)) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
/** | ||
* Wrapper around {@link isTextSync} for sync signature and {@link isTextCallback} async signature. | ||
* In a later major release, {@link isTextSync}.will become this function, so if you prefer the callback interface you should use {@link isTextCallback}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @param {IsTextCallback} [callback] If provided, void will be returned, as the result will provided to the callback. | ||
* @returns {TextOrBinaryResult|void} If no callback was provided, then the result is returned. | ||
*/ | ||
function isText(filename, buffer, callback) { | ||
if (callback) { | ||
return isTextCallback(filename, buffer, callback) | ||
} else return isTextSync(filename, buffer) | ||
} | ||
/** | ||
* Inverse wrapper for {@link isTextSync}. | ||
* In a later major release, this function will become {@link isBinary} so you should use that instead. | ||
* @param {string} [filename] | ||
* @param {Buffer} [buffer] | ||
* @returns {TextOrBinaryResult} | ||
*/ | ||
function isBinarySync(filename, buffer) { | ||
var text = isTextSync(filename, buffer) | ||
export function isBinary(filename, buffer) { | ||
const text = isText(filename, buffer) | ||
if (text == null) return null | ||
@@ -218,104 +53,53 @@ return !text | ||
/** | ||
* Callback wrapper for {@link isBinarySync}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @param {IsTextCallback} callback | ||
* @returns {void} | ||
*/ | ||
function isBinaryCallback(filename, buffer, callback) { | ||
var result | ||
try { | ||
result = isBinarySync(filename, buffer) | ||
} catch (err) { | ||
callback(err) | ||
} | ||
callback(null, result) | ||
} | ||
/** | ||
* Promise wrapper for {@link isBinarySync}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @returns {Promise<TextOrBinaryResult>} | ||
*/ | ||
function isBinaryPromise(filename, buffer) { | ||
try { | ||
return Promise.resolve(isBinarySync(filename, buffer)) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
/** | ||
* Wrapper around {@link isBinarySync} for sync signature and {@link isBinaryCallback} async signature. | ||
* In a later major release, {@link isBinarySync}.will become this function, so if you prefer the callback interface you should use {@link isBinaryCallback}. | ||
* @param {string?} filename | ||
* @param {Buffer?} buffer | ||
* @param {IsTextCallback} [callback] If provided, void will be returned, as the result will provided to the callback. | ||
* @returns {TextOrBinaryResult|void} If no callback was provided, then the result is returned. | ||
*/ | ||
function isBinary(filename, buffer, callback) { | ||
if (callback) { | ||
return isBinaryCallback(filename, buffer, callback) | ||
} else return isBinarySync(filename, buffer) | ||
} | ||
/** | ||
* Get the encoding of a buffer. | ||
* Checks the start, middle, and end of the buffer for characters that are unrecognized within UTF8 encoding. | ||
* History has shown that inspection at all three locations is necessary. | ||
* In a later major release, this function will become {@link getEncoding} so you should use that instead. | ||
* @param {Buffer} buffer | ||
* @param {EncodingOpts} [opts] | ||
* @returns {EncodingResult} | ||
* @returns Will be `null` if `buffer` was not provided. Otherwise will be either `'utf8'` or `'binary'` | ||
*/ | ||
function getEncodingSync(buffer, opts) { | ||
export function getEncoding(buffer, opts) { | ||
var _a, _b | ||
// Check | ||
if (!buffer) return null // Prepare | ||
var textEncoding = 'utf8' | ||
var binaryEncoding = 'binary' // Discover | ||
if (opts == null) { | ||
if (!buffer) return null | ||
// Prepare | ||
const textEncoding = 'utf8' | ||
const binaryEncoding = 'binary' | ||
const chunkLength = | ||
(_a = opts === null || opts === void 0 ? void 0 : opts.chunkLength) !== | ||
null && _a !== void 0 | ||
? _a | ||
: 24 | ||
let chunkBegin = | ||
(_b = opts === null || opts === void 0 ? void 0 : opts.chunkBegin) !== | ||
null && _b !== void 0 | ||
? _b | ||
: 0 | ||
// Discover | ||
if ((opts === null || opts === void 0 ? void 0 : opts.chunkBegin) == null) { | ||
// Start | ||
var chunkLength = 24 | ||
var encoding = getEncodingSync(buffer, { | ||
chunkLength: chunkLength, | ||
}) | ||
let encoding = getEncoding(buffer, { chunkLength, chunkBegin }) | ||
if (encoding === textEncoding) { | ||
// Middle | ||
var chunkBegin = Math.max(0, Math.floor(buffer.length / 2) - chunkLength) | ||
encoding = getEncodingSync(buffer, { | ||
chunkLength: chunkLength, | ||
chunkBegin: chunkBegin, | ||
chunkBegin = Math.max(0, Math.floor(buffer.length / 2) - chunkLength) | ||
encoding = getEncoding(buffer, { | ||
chunkLength, | ||
chunkBegin, | ||
}) | ||
if (encoding === textEncoding) { | ||
// End | ||
chunkBegin = Math.max(0, buffer.length - chunkLength) | ||
encoding = getEncodingSync(buffer, { | ||
chunkLength: chunkLength, | ||
chunkBegin: chunkBegin, | ||
encoding = getEncoding(buffer, { | ||
chunkLength, | ||
chunkBegin, | ||
}) | ||
} | ||
} // Return | ||
} | ||
// Return | ||
return encoding | ||
} else { | ||
// Extract | ||
var _opts$chunkLength = opts.chunkLength, | ||
_chunkLength = _opts$chunkLength === void 0 ? 24 : _opts$chunkLength, | ||
_opts$chunkBegin = opts.chunkBegin, | ||
_chunkBegin = _opts$chunkBegin === void 0 ? 0 : _opts$chunkBegin | ||
var chunkEnd = Math.min(buffer.length, _chunkBegin + _chunkLength) | ||
var contentChunkUTF8 = buffer.toString(textEncoding, _chunkBegin, chunkEnd) // Detect encoding | ||
for (var i = 0; i < contentChunkUTF8.length; ++i) { | ||
var charCode = contentChunkUTF8.charCodeAt(i) | ||
const chunkEnd = Math.min(buffer.length, chunkBegin + chunkLength) | ||
const contentChunkUTF8 = buffer.toString(textEncoding, chunkBegin, chunkEnd) | ||
// Detect encoding | ||
for (let i = 0; i < contentChunkUTF8.length; ++i) { | ||
const charCode = contentChunkUTF8.charCodeAt(i) | ||
if (charCode === 65533 || charCode <= 8) { | ||
@@ -327,73 +111,6 @@ // 8 and below are control characters (e.g. backspace, null, eof, etc.) | ||
} | ||
} // Return | ||
} | ||
// Return | ||
return textEncoding | ||
} | ||
} | ||
/** | ||
* Get the encoding of a buffer. | ||
* Uses {@link getEncodingSync} behind the scenes. | ||
* @param {Buffer} buffer | ||
* @param {EncodingOpts} [opts] | ||
* @param {GetEncodingCallback} callback | ||
* @returns {void} | ||
*/ | ||
function getEncodingCallback(buffer, opts, callback) { | ||
if (typeof opts === 'function' && callback == null) | ||
return getEncodingCallback(buffer, null, opts) | ||
/** @type {EncodingResult?} */ | ||
var result | ||
try { | ||
result = getEncodingSync(buffer, opts) | ||
} catch (err) { | ||
callback(err) | ||
} | ||
callback(null, result) | ||
} | ||
/** | ||
* Promise wrapper for {@link getEncodingSync}. | ||
* @param {Buffer} buffer | ||
* @param {EncodingOpts} [opts] | ||
* @returns {Promise<EncodingResult>} | ||
*/ | ||
function getEncodingPromise(buffer, opts) { | ||
try { | ||
return Promise.resolve(getEncodingSync(buffer, opts)) | ||
} catch (err) { | ||
return Promise.reject(err) | ||
} | ||
} | ||
/** | ||
* Wrapper around {@link getEncodingSync} for sync signature and {@link getEncodingCallback} async signature. | ||
* In a later major release, {@link getEncodingSync}.will become this function, so if you prefer the callback interface you should use {@link getEncodingCallback}. | ||
* @param {Buffer} buffer | ||
* @param {EncodingOpts} [opts] | ||
* @param {GetEncodingCallback} [callback] If provided, void will be returned, as the result will provided to the callback. | ||
* @returns {EncodingResult|void} If no callback was provided, then the result is returned. | ||
*/ | ||
function getEncoding(buffer, opts, callback) { | ||
if (callback || typeof opts === 'function') { | ||
return getEncodingCallback(buffer, opts, callback) | ||
} else return getEncodingSync(buffer, opts) | ||
} // Export | ||
module.exports = { | ||
isTextSync: isTextSync, | ||
isTextCallback: isTextCallback, | ||
isTextPromise: isTextPromise, | ||
isText: isText, | ||
isBinarySync: isBinarySync, | ||
isBinaryCallback: isBinaryCallback, | ||
isBinaryPromise: isBinaryPromise, | ||
isBinary: isBinary, | ||
getEncoding: getEncoding, | ||
getEncodingSync: getEncodingSync, | ||
getEncodingPromise: getEncodingPromise, | ||
getEncodingCallback: getEncodingCallback, | ||
} |
# History | ||
## v5.0.0 2020 May 30 | ||
- Potential Breaking Change: Removed the long-standing deprecated sync, callback, and promise wrappers, now the only exports are `isText`, `isBinary`, and `getEncoding` | ||
- Potential Breaking Change: `getEncoding` now checks start, middle, and end if `checkBegin` was not provided. Prior functionality only checked start, middle, and end, if `opts` were not provided. This new functionality allows custom `checkLength` for start, middle, and end. | ||
- Converted to TypeScript, and provided proper documentation for `isBinary` instead of just referencing `isText`, so your intellisense is now more helpful | ||
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation) | ||
## v4.3.0 2020 May 22 | ||
@@ -4,0 +11,0 @@ |
106
package.json
{ | ||
"title": "Is Text or Binary?", | ||
"name": "istextorbinary", | ||
"version": "4.3.0", | ||
"version": "5.0.0-next.1590821539.444b08db17a7f4c6dd041d6f3d05c4e7d7fbbf5f", | ||
"description": "Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.", | ||
@@ -15,3 +15,3 @@ "homepage": "https://github.com/bevry/istextorbinary", | ||
"encoding", | ||
"esnext", | ||
"es2019", | ||
"ext", | ||
@@ -32,2 +32,3 @@ "extension", | ||
"istextfile", | ||
"module", | ||
"node", | ||
@@ -37,3 +38,4 @@ "path", | ||
"typed", | ||
"types" | ||
"types", | ||
"typescript" | ||
], | ||
@@ -103,4 +105,14 @@ "badges": { | ||
{ | ||
"description": "ESNext source code for Node.js with Require for modules", | ||
"description": "TypeScript source code with Import for modules", | ||
"directory": "source", | ||
"entry": "index.ts", | ||
"tags": [ | ||
"typescript", | ||
"import" | ||
], | ||
"engines": false | ||
}, | ||
{ | ||
"description": "TypeScript compiled against ESNext for Node.js with Require for modules", | ||
"directory": "edition-esnext", | ||
"entry": "index.js", | ||
@@ -113,2 +125,16 @@ "tags": [ | ||
"engines": { | ||
"node": "14", | ||
"browsers": false | ||
} | ||
}, | ||
{ | ||
"description": "TypeScript compiled against ES2019 for Node.js with Require for modules", | ||
"directory": "edition-es2019", | ||
"entry": "index.js", | ||
"tags": [ | ||
"javascript", | ||
"es2019", | ||
"require" | ||
], | ||
"engines": { | ||
"node": "10 || 12 || 13 || 14", | ||
@@ -119,3 +145,3 @@ "browsers": false | ||
{ | ||
"description": "ESNext compiled for web browsers with Require for modules", | ||
"description": "TypeScript compiled against ES2019 for web browsers with Import for modules", | ||
"directory": "edition-browsers", | ||
@@ -125,3 +151,3 @@ "entry": "index.js", | ||
"javascript", | ||
"require" | ||
"import" | ||
], | ||
@@ -134,37 +160,42 @@ "engines": { | ||
], | ||
"types": "./compiled-types/", | ||
"type": "commonjs", | ||
"main": "source/index.js", | ||
"main": "index.js", | ||
"browser": "edition-browsers/index.js", | ||
"module": "edition-browsers/index.js", | ||
"dependencies": { | ||
"binaryextensions": "^3.0.0", | ||
"textextensions": "^4.3.0" | ||
"binaryextensions": "^4.0.0", | ||
"editions": "^3.3.0", | ||
"textextensions": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@bevry/update-contributors": "^1.7.0", | ||
"@bevry/update-contributors": "^1.8.0", | ||
"@typescript-eslint/eslint-plugin": "^3.0.2", | ||
"@typescript-eslint/parser": "^3.0.2", | ||
"assert-helpers": "^6.6.0", | ||
"eslint": "^7.0.0", | ||
"eslint": "^7.1.0", | ||
"eslint-config-bevry": "^3.7.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jsdoc": "^3.6.4", | ||
"kava": "^5.2.0", | ||
"minami": "^1.2.3", | ||
"kava": "^5.3.0", | ||
"prettier": "^2.0.5", | ||
"projectz": "^2.3.0", | ||
"projectz": "^2.4.0", | ||
"surge": "^0.21.3", | ||
"valid-directory": "^2.1.0" | ||
"typedoc": "^0.17.7", | ||
"typescript": "^3.9.3", | ||
"valid-directory": "^2.2.0", | ||
"valid-module": "^1.3.0" | ||
}, | ||
"scripts": { | ||
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out ./.next", | ||
"our:compile": "npm run our:compile:edition-browsers", | ||
"our:compile:edition-browsers": "env BABEL_ENV=edition-browsers babel --out-dir ./edition-browsers ./source", | ||
"our:compile": "npm run our:compile:edition-browsers && npm run our:compile:edition-es2019 && npm run our:compile:edition-esnext && npm run our:compile:types", | ||
"our:compile:edition-browsers": "tsc --module ESNext --target ES2019 --outDir ./edition-browsers --project tsconfig.json && ( test ! -d edition-browsers/source || ( mv edition-browsers/source edition-temp && rm -Rf edition-browsers && mv edition-temp edition-browsers ) )", | ||
"our:compile:edition-es2019": "tsc --module commonjs --target ES2019 --outDir ./edition-es2019 --project tsconfig.json && ( test ! -d edition-es2019/source || ( mv edition-es2019/source edition-temp && rm -Rf edition-es2019 && mv edition-temp edition-es2019 ) )", | ||
"our:compile:edition-esnext": "tsc --module commonjs --target ESNext --outDir ./edition-esnext --project tsconfig.json && ( test ! -d edition-esnext/source || ( mv edition-esnext/source edition-temp && rm -Rf edition-esnext && mv edition-temp edition-esnext ) )", | ||
"our:compile:types": "tsc --project tsconfig.json --emitDeclarationOnly --declaration --declarationMap --declarationDir ./compiled-types && ( test ! -d compiled-types/source || ( mv compiled-types/source edition-temp && rm -Rf compiled-types && mv edition-temp compiled-types ) )", | ||
"our:deploy": "echo no need for this project", | ||
"our:meta": "npm run our:meta:contributors && npm run our:meta:docs && npm run our:meta:projectz", | ||
"our:meta:contributors": "update-contributors", | ||
"our:meta:docs": "npm run our:meta:docs:jsdoc", | ||
"our:meta:docs:jsdoc": "rm -Rf ./docs && jsdoc --recurse --pedantic --access all --destination ./docs --package ./package.json --readme ./README.md --template ./node_modules/minami ./source && mv ./docs/$npm_package_name/$npm_package_version/* ./docs/ && rm -Rf ./docs/$npm_package_name/$npm_package_version", | ||
"our:meta:docs": "npm run our:meta:docs:typedoc", | ||
"our:meta:docs:typedoc": "rm -Rf ./docs && typedoc --mode file --exclude '**/+(*test*|node_modules)' --excludeExternals --name \"$npm_package_name\" --readme ./README.md --out ./docs ./source", | ||
"our:meta:projectz": "projectz compile", | ||
@@ -180,7 +211,8 @@ "our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push", | ||
"our:test": "npm run our:verify && npm test", | ||
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:prettier", | ||
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:module && npm run our:verify:prettier", | ||
"our:verify:directory": "valid-directory", | ||
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source", | ||
"our:verify:module": "valid-module", | ||
"our:verify:prettier": "prettier --write .", | ||
"test": "node ./source/test.js" | ||
"test": "node ./test.js" | ||
}, | ||
@@ -195,25 +227,3 @@ "eslintConfig": { | ||
"singleQuote": true | ||
}, | ||
"babel": { | ||
"env": { | ||
"edition-browsers": { | ||
"sourceType": "script", | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"esmodules": false, | ||
"browsers": "defaults" | ||
}, | ||
"modules": false | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"@babel/proposal-object-rest-spread" | ||
] | ||
} | ||
} | ||
} | ||
} |
@@ -53,7 +53,17 @@ <!-- TITLE/ --> | ||
[Complete API Documentation.](http://master.istextorbinary.bevry.surge.sh/docs/index.html) | ||
[Complete API Documentation.](http://master.istextorbinary.bevry.surge.sh/docs/globals.html) | ||
```typescript | ||
import { isText, isBinary, getEncoding } from 'istextorbinary' | ||
``` | ||
or | ||
```javascript | ||
const { isText, isBinary, getEncoding } = require('istextorbinary') | ||
``` | ||
then | ||
```javascript | ||
isText(aFilename) // returns true if a text file otherwise false, checks only filename | ||
@@ -83,2 +93,18 @@ isText(null, aBuffer) // returns true if a text file otherwise false, checks only buffer | ||
<a href="https://www.pika.dev/cdn" title="100% Native ES Modules CDN"><h3>pika</h3></a> | ||
``` html | ||
<script type="module"> | ||
import * as pkg from '//cdn.pika.dev/istextorbinary/^5.0.0' | ||
</script> | ||
``` | ||
<a href="https://unpkg.com" title="unpkg is a fast, global content delivery network for everything on npm"><h3>unpkg</h3></a> | ||
``` html | ||
<script type="module"> | ||
import * as pkg from '//unpkg.com/istextorbinary@^5.0.0' | ||
</script> | ||
``` | ||
<a href="https://jspm.io" title="Native ES Modules CDN"><h3>jspm</h3></a> | ||
@@ -88,3 +114,3 @@ | ||
<script type="module"> | ||
import * as pkg from '//dev.jspm.io/istextorbinary@4.3.0' | ||
import * as pkg from '//dev.jspm.io/istextorbinary@5.0.0' | ||
</script> | ||
@@ -97,18 +123,8 @@ ``` | ||
<ul><li><code>istextorbinary</code> aliases <code>istextorbinary/source/index.js</code></li> | ||
<li><code>istextorbinary/source/index.js</code> is <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> source code for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>istextorbinary/edition-browsers/index.js</code> is <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> compiled for web browsers with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul> | ||
<ul><li><code>istextorbinary</code> aliases <code>istextorbinary/index.js</code> which uses the <a href="https://github.com/bevry/editions" title="You can use the Editions Autoloader to autoload the appropriate edition for your consumers environment">Editions Autoloader</a> to automatically select the correct edition for the consumer's environment</li> | ||
<li><code>istextorbinary/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li> | ||
<li><code>istextorbinary/edition-esnext/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>istextorbinary/edition-es2019/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_-_ECMAScript_2019" title="ECMAScript ES2019">ES2019</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>istextorbinary/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_-_ECMAScript_2019" title="ECMAScript ES2019">ES2019</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li></ul> | ||
<h3><a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a></h3> | ||
This project provides its type information via inline <a href="http://usejsdoc.org" title="JSDoc is an API documentation generator for JavaScript, similar to Javadoc or phpDocumentor">JSDoc Comments</a>. To make use of this in <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a>, set your <code>maxNodeModuleJsDepth</code> compiler option to `5` or thereabouts. You can accomlish this via your `tsconfig.json` file like so: | ||
``` json | ||
{ | ||
"compilerOptions": { | ||
"maxNodeModuleJsDepth": 5 | ||
} | ||
} | ||
``` | ||
<!-- /INSTALL --> | ||
@@ -115,0 +131,0 @@ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
54869
16
13
204
3
527
1
1
+ Addededitions@^3.3.0
+ Addedbinaryextensions@4.19.0(transitive)
+ Addededitions@3.16.0(transitive)
+ Addederrlop@3.17.0(transitive)
+ Addedsemver@6.3.0(transitive)
+ Addedtextextensions@5.16.0(transitive)
- Removedbinaryextensions@3.0.0(transitive)
- Removedtextextensions@4.4.0(transitive)
Updatedbinaryextensions@^4.0.0
Updatedtextextensions@^5.0.0