How to use binary-extensions - 8 common examples

To help you get started, we’ve selected a few binary-extensions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beakerbrowser / beaker / app / lib / mime.js View on Github external
export function isFileNameBinary (filepath) {
  const ext = path.extname(filepath)
  if (binextensions.includes(ext)) return true
  if (textextensions.includes(ext)) return false
  // dont know
}
github beakerbrowser / beaker-core / lib / mime.js View on Github external
exports.isFileNameBinary = function (filepath) {
  const ext = path.extname(filepath)
  if (binextensions.includes(ext)) return true
  if (textextensions.includes(ext)) return false
  // dont know
}
github rdgd / twly / index.js View on Github external
function isTextFile (filePath) {
  return !binaries.includes(filePath.split('.').pop());
}
github beakerbrowser / beaker / app / builtin-pages / com / files-browser / file-preview.js View on Github external
function isBinaryExtension (fileName) {
  var nameParts = fileName.split('.')
  if (nameParts.length > 1) {
    var ext = nameParts.pop()
    if (ext && BINARY_EXTENSIONS.includes(ext.toLowerCase()) === true) {
      return true
    }
  }
  return false
}
github beakerbrowser / beaker / app / builtin-pages / com / library / createfile-popup.js View on Github external
function isBinaryExtension (fileName) {
  var nameParts = fileName.split('.')
  if (nameParts.length > 1) {
    lastTriedExt = nameParts.pop()
    if (lastTriedExt && BINARY_EXTENSIONS.includes(lastTriedExt.toLowerCase()) === true) {
      return true
    }
  }
  return false
}
github pantojs / panto / src / fileutils.js View on Github external
isBinary(filepath) {
        const ext = path.extname(filepath).slice(1).toLowerCase();
        return (this.options.binary_resource || '').toLowerCase().split(',').indexOf(ext) > -1 || binaryExtensions.indexOf(ext) > -1;
    }
    locate(name) {
github GoogleContainerTools / kpt / docsy / node_modules / is-binary-path / index.js View on Github external
*
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';
var path = require('path');
var binaryExtensions = require('binary-extensions');
var exts = Object.create(null);

binaryExtensions.forEach(function (el) {
	exts[el] = true;
});

module.exports = function (filepath) {
	return path.extname(filepath).slice(1).toLowerCase() in exts;
};
github 1000ch / rog / index.js View on Github external
'use strict';

const got = require('got');
const isURL = require('is-url');
const binaryExtensions = require('binary-extensions');
const isHTML = require('is-html');
const cheerio = require('cheerio');
const jschardet = require('jschardet');
const iconv = require('iconv-lite');

const binaries = new RegExp(`(${binaryExtensions.map(ext => `.${ext}`).join('|')})$`);

const getBody = response => {
  const headers = response.headers || {};
  const body = response.body || '';

  const contentType = headers['content-type'] || '';
  const matches = contentType.match(/charset=(?.+)/);
  if (matches !== null) {
    return iconv.decode(body, matches[1]);
  }

  const result = jschardet.detect(body);
  if (result && result.encoding && (result.confidence || 0) >= 0.99) {
    return iconv.decode(body, result.encoding);
  }

binary-extensions

List of binary file extensions

MIT
Latest version published 8 months ago

Package Health Score

82 / 100
Full package analysis