How to use textextensions - 4 common examples

To help you get started, we’ve selected a few textextensions 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 bevry / istextorbinary / source / index.js View on Github external
function isTextSync(filename, buffer) {
	// 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) {
				return true
			}
			if (binaryExtensions.indexOf(extension) !== -1) {
				return false
			}
		}
	}

	// Fallback to encoding if extension check was not enough
	if (buffer) {
		return getEncodingSync(buffer) === 'utf8'
	}

	// No buffer was provided
	return null
}
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 OpusCapita / filemanager / packages / server-nodejs / router / lib.js View on Github external
'use strict';

const path = require('path');
const fs = require('fs-extra');
const { platform } = require('os');
const { promisify } = require('util');
const _isBinaryFile = promisify(require('isbinaryfile'));
const textExtensions = require('textextensions').concat('gsp');
const binaryExtensions = require('binaryextensions');

const getClientIp = require('../utils/get-client-ip');

const {
  encode: path2id,
  decode
} = require('../utils/id');

const {
  TYPE_FILE,
  TYPE_DIR
} = require('../constants');

const
  UNKNOWN_RESOURCE_TYPE_ERROR = 'Unknown resource type',

textextensions

A package that contains an array of every single file extension there is for text files

Artistic-2.0
Latest version published 10 months ago

Package Health Score

76 / 100
Full package analysis