# file-type-js

> A file type checking library

Latest version **0.1.0** (published 2019-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-type-js
pnpm add file-type-js
yarn add file-type-js
bun add file-type-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-11-14 |
| First published | 2019-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lanyueos@qq.com |
| Maintainers | lanyue |
| Keywords | file-type |

## Links

- npm: https://www.npmjs.com/package/file-type-js
- Repository: https://github.com/mengdu/file-type
- Homepage: https://github.com/mengdu/file-type#readme
- Issues: https://github.com/mengdu/file-type/issues
- npm.io page: https://npm.io/package/file-type-js

## Recent versions

- 0.1.0 (latest) — 2019-11-14

## README

# file-type

A file type checking library

> Detect the file type from Buffer, ArrayBuffer, File, Bolb

```ls
npm install file-type-js
```

```js
const FileType = require('file-type-js')
const buf = fs.readFileSync(path.resolve(__dirname, 'files/test.jpg'))

console.log(await FileType.is(buf, 'jpg'))
```

**browser**

```html
<script src="./file-type.js"></script>
<script>
  fileInput.addEventListener('change', function () {
    console.log(fileInput.files)
    var file = fileInput.files[0]

    if (!file) return

    var extname = (file.name.match(/\.(\w*)$/)[1]).toLocaleLowerCase()

    $FileType.is(file, extname).then(function (valid) {
      console.log(extname, valid)
    })
  })
</script>
```

## Other

[file-type](https://github.com/sindresorhus/file-type)

---
_Source: https://npm.io/package/file-type-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
