# @otoniel19/filetype.js

> filetype.js get the type of file by extension name using node.js

Latest version **1.1.5** (published 2022-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @otoniel19/filetype.js
pnpm add @otoniel19/filetype.js
yarn add @otoniel19/filetype.js
bun add @otoniel19/filetype.js
```

Provides the command `filetype`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2022-03-19 |
| First published | 2022-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 22.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | otoniel |
| Keywords | mime, jsdom, html, fileinfo, filetype, information, node.js, client, filetype.js |

## Links

- npm: https://www.npmjs.com/package/@otoniel19/filetype.js
- Repository: https://github.com/otoniel19/filetype.js
- Homepage: https://github.com/otoniel19/filetype.js#readme
- Issues: https://github.com/otoniel19/filetype.js/issues
- npm.io page: https://npm.io/package/@otoniel19/filetype.js

## Dependencies (8)

- [mime](https://npm.io/package/mime.md) latest
- [jsdom](https://npm.io/package/jsdom.md) ^19.0.0
- [colors](https://npm.io/package/colors.md) ^1.4.0
- [mime-db](https://npm.io/package/mime-db.md) latest
- [stormdb](https://npm.io/package/stormdb.md) ^0.5.2
- [commander](https://npm.io/package/commander.md) ^9.0.0
- [cli-table3](https://npm.io/package/cli-table3.md) ^0.6.1
- [string-strip-html](https://npm.io/package/string-strip-html.md) 8.3.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2022-03-19
- 1.1.4 — 2022-03-14
- 1.1.3 — 2022-03-14
- 1.1.2 — 2022-03-13
- 1.1.1 — 2022-03-11
- 1.1.0 — 2022-03-11
- 1.0.9 — 2022-03-10
- 1.0.8 — 2022-03-10
- 1.0.7 — 2022-03-10
- 1.0.6 — 2022-03-10
- 1.0.5 — 2022-03-09
- 1.0.4 — 2022-03-09
- 1.0.3 — 2022-03-09
- 1.0.2 — 2022-03-08
- 1.0.1 — 2022-03-08
- … 1 more at https://npm.io/package/@otoniel19/filetype.js/versions

## README

# filetype.js

> filetype.js and a module to let you get information from a extension
> <br>
> Information from [FileInfo - The File Extensions Database](https://fileinfo.com)

# usage

> filetype.js supports all mimetypes in [mimedb](https://raw.githubusercontent.com/jshttp/mime-db/master/db.json)

# get info by extension or mimetype

```js
const filetype = require("@otoniel19/filetype.js");
filetype.get("js").then(console.log); // by extension
filetype.get("application/javascript"); //by mimetype
```

- output:

```json
{
  "extname": "js",
  "results": [
    {
      "name": "JavaScript File",
      "description": "A JS file is a text file containing JavaScript code that is used to execute JavaScript instructions in webpages. It may include functions that open and close windows, validate form fields, enable rollover images, or create dropdown menus.",
      "mimetype": "application/javascript",
      "category": "web",
      "type": "text",
      "popularity": "[Object]"
    },
    {
      "name": "JScript Executable Script",
      "description": "JS files are referenced by webpages that incorporate JavaScript functions. They are usually imported in the or sections of the HTML. JS files are helpful when the same JavaScript code is used in multiple webpages as they allow the different pages to reference the code in the one external JS file.",
      "mimetype": "application/javascript",
      "category": "executable",
      "type": "unknown",
      "popularity": "[Object]"
    }
  ]
}
```

# search by extension info

> you can search by name or mimetype

```js
const filetype = require("@otoniel19/filetype.js");
filetype.search("js").then(console.log);
```

- output:

```json
{
  "searchBy": "js",
  "results": []
}
```

> the search has too many results.

# cli

- you can run filetype --help to see commands

```sh
$ filetype --help
> Usage: filetype [options] [command]
> filetype view the type of file
>
> Options:
>  -V, --version   output the version number
>  -h, --help      display help for command
>
> Commands:
>  cache           show the cache
>  get <extname>   get the file type info
>  search <name>   search by extensions
>  help [command]  display help for command
```

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