Gathering detailed insights and metrics for omni-file
Gathering detailed insights and metrics for omni-file
Gathering detailed insights and metrics for omni-file
Gathering detailed insights and metrics for omni-file
You got a filename/foldername we got all its info: icon, category, type, extensions, mime type, color, and more...
npm install omni-file
Typescript
Module System
Node Version
NPM Version
75.8
Supply Chain
99.5
Quality
82.4
Maintenance
100
Vulnerability
100
License
TypeScript (93.6%)
JavaScript (4.1%)
CSS (1.42%)
HTML (0.89%)
Total Downloads
1,102
Last Day
1
Last Week
15
Last Month
89
Last Year
1,102
5 Stars
91 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.3.3
Package Id
omni-file@1.3.3
Unpacked Size
1.68 MB
Size
412.80 kB
File Count
992
NPM Version
10.8.2
Node Version
20.18.0
Publised On
18 Nov 2024
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-16.7%
15
Compared to previous week
Last month
111.9%
89
Compared to previous month
Last year
0%
1,102
Compared to previous year
Omni-file is a comprehensive file information extractor that provides language, icon, type, and MIME information for any file based on its name or extension. With over 1000 icons, support for more than 700 programming languages, and only 79.4 kB gzipped, it's both powerful and lightweight!
It leverages GitHub Linguist data and Material Icon Theme for up-to-date and accurate file type detection and icons. The data is regularly updated to ensure the latest language and icon information.
Install omni-file from npm:
1npm install omni-file 2pnpm add omni-file 3yarn add omni-file
getIcon
1import { getIcon } from "omni-file"; 2 3console.log(getIcon("example.js")); // Output: 'javascript' 4console.log(getIcon("styles.css")); // Output: 'css' 5console.log(getIcon("data.json")); // Output: 'json' 6console.log(getIcon("package.json")); // Output: 'nodejs' 7console.log(getIcon("Dockerfile")); // Output: 'docker' 8console.log(getIcon(".gitignore")); // Output: 'git' 9console.log(getIcon("src", { isFolder: true })); // Output: 'folder-src' 10console.log(getIcon("node_modules", { isFolder: true })); // Output: 'folder-node' 11console.log(getIcon("tests", { isFolder: true, isExpanded: true })); // Output: 'folder-test-open' 12console.log(getIcon("vercel.json", { isLight: true })); // Output: 'vercel_light' 13console.log(getIcon("example.test.js")); // Output: 'test-js' 14console.log(getIcon("component.spec.ts")); // Output: 'test-ts' 15console.log(getIcon(path.join("src", "components", "Button.tsx"))); // Output: 'react_ts' 16console.log(getIcon(path.join("tests", "unit", "utils.test.js"))); // Output: 'test-js' 17console.log(getIcon(".eslintrc.json")); // Output: 'eslint' 18console.log(getIcon(".prettierrc")); // Output: 'prettier' 19console.log(getIcon("tsconfig.json")); // Output: 'tsconfig' 20console.log(getIcon("README.md")); // Output: 'readme' 21console.log(getIcon("readme.md")); // Output: 'readme' 22console.log(getIcon("DockerFile")); // Output: 'docker' 23console.log(getIcon("dockerfile")); // Output: 'docker'
1import { getLanguage } from "omni-file"; 2 3console.log(getLanguage("folder/example.ts"));
Output:
1{ 2 "type": "programming", 3 "color": "#3178c6", 4 "aliases": ["ts"], 5 "interpreters": ["deno", "ts-node", "tsx"], 6 "extensions": [".ts", ".cts", ".mts"], 7 "tm_scope": "source.ts", 8 "ace_mode": "typescript", 9 "codemirror_mode": "javascript", 10 "codemirror_mime_type": "application/typescript", 11 "language_id": 378, 12 "name": "TypeScript", 13 "icons": ["typescript", "javascript"] 14}
Note that you can also get icons from
getLanguage
by usinggetLanguage(filename)?.icons
but the answer may be less accurate. (folder icons are not included this way)
getIcon
1import { getIcon } from "omni-file"; 2 3const icon = getIcon("folder/example.ts"); // "typescript" 4const svgUrl = `node_modules/omni-file/icons/${icon}.svg`; 5 6<img src={svgUrl} alt={icon} />;
Output:
1import { languages, icons } from "omni-file"; 2 3console.log(languages["JavaScript"].extensions); // -> [ ".js",".cjs",".es",".jsm", ... ] 4console.log(icons.fileExtensions["js"]); // -> "javascript"
Omni-file provides two icon sets:
You can switch between these themes based on your application's needs:
1import { getIcon, IconTheme } from "omni-file"; 2 3const darkIcon = getIcon("example.ts", { isLight: false }); 4const lightIcon = getIcon("example.ts", { isLight: true });
To set up the project for development:
1pnpm install
1pnpm run update-data
1pnpm run build
1pnpm test
build
: Builds the project using tsupbuild:watch
: Watches for changes and rebuildstest
: Runs the test suitetest:coverage
: Runs tests with coverage reportingupdate-data
: Updates the Linguist datapostinstall
: Automatically updates data after installationContributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.