which-fileextension
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

which-fileextension

detect if a file extension is text/ binary or file is text/ binary

  • detect file extensions
  • check your file extension using provided string or array
  • check if file is part of list of extension
  • detect file extension is text
  • detect file extension is binary
  • detect if file is text
  • detect if file is binary

USAGE

detect, isExtension, isTextExtension, isBinaryExtension,

const dr = require("which-fileextension");

dr.detect("test/tester.jpg", dr.binaryExtensions) // true
dr.detect("test/tester.jpg", dr.textExtensions) // false
dr.detect("test/tester.jpg", ["gz", "txt", "jpg", "jpeg"]) // true`
dr.isExtension("test/tester.jpg", "jpg") // true
dr.isExtension("test/tester.jpg", "txt") // false
dr.isTextExtension("test/tester.txt") // true
dr.isTextExtension("test/tester.jpeg") // false
dr.isBinaryExtension("test/tester.jpeg") // true

isText, isBinary

const dr = require("which-fileextension");

dr.isText("test/tester.txt") // true
dr.isBinary("test/tester.exe") // true

binaryExtensions, textExtensions

const dr = require("which-fileextension");

console.log(dr.textExtensions);
console.log(dr.binaryExtensions);
dr.detect("test/tester.jpg", dr.binaryExtensions) // true
dr.detect("test/tester.jpg", dr.textExtensions) // false

Credits and References:

binaryextensions textextensions istextorbinary

/which-fileextension/

    Package Sidebar

    Install

    npm i which-fileextension

    Weekly Downloads

    9

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    58.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • ganeshkbhat