![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@crabnebula/file-icons
Advanced tools
file-icons
File Icons for IDEs
This package provides simple & fast programmatic access to the icons from vscode-icons, letting you use them in your own projects!
There are only two functions exported from this package: getIconForFile
and
getIconForFolder
. They employ a matching heuristic similar to the one used in
vscode-icons to find the best matching icon for a given file or folder.
Note that this heuristic is simplified from the
vscode-icons
one, so it may not be as accurate or complete. It should be good enough though, but feel free to open a PR if you find any issues!
For usage in JavaScript/TypeScript projects:
npm install file-icons
# OR
yarn add file-icons
# OR
pnpm add file-icons
For usage in Rust projects:
cargo add file-icons
getIconForFile
returns the URL of the icon for a given file or null
if no
matching icon could be found. You MUST call setCDN
before calling this
function with a valid URL to where the icons from this package are hosted.
import { getIconForFile, setCDN } from "file-icons";
setCDN("/icons/"); // point this to wherever you have hosted the file-icons/icons folder
const icon = getIconForFile("foo.js");
getIconForFolder
returns the URL of the icon for a given folder or null
if
no matching icon could be found. You MUST call setCDN
before calling this
function with a valid URL to where the icons from this package are hosted.
import { getIconForFolder, setCDN } from "file-icons";
setCDN("/icons/"); // point this to wherever you have hosted the file-icons/icons folder
const icon = getIconForFolder(".github");
This package can also be used as a Rust crate. The API is a bit lower level
though, i.e. instead of returning a URL to the icon, it returns the u64
ID of
the icon. Each ID maps to a .svg
file in the icons
folder.
use file_icons::get_icon_for_file;
fn main() {
let icon = get_icon_for_file("foo.js"); // Returns the ID of the icon
println!("{}", icon);
}
You said fast, but how fast is t really?
Well, plenty! Here's the benchmark results on a 2023 MacBook Pro:
[ min mean max ]
_get_icon_for_file time: [42.963 ns 43.045 ns 43.134 ns]
_get_icon_for_folder time: [68.751 ns 68.879 ns 69.019 ns]
and here is the same running as WebAssembly in Safari on that same 2023 MacBook Pro:
[ min mean max ]
_get_icon_for_file time: [53.251 ns 53.374 ns 53.538 ns]
_get_icon_for_folder time: [70.595 ns 70.680 ns 70.771 ns]
If you are using Vite as your build tool you might want to use the plugin vite-plugin-static-copy to pull the icons from the node_modules folder.
Just install the plugin with
Taken from the plugin README
npm i -D vite-plugin-static-copy # yarn add -D vite-plugin-static-copy
and add the following configuration to your vite.config.js
/ vite.config.ts
// vite.config.js / vite.config.ts
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { normalizePath } from "vite";
export default {
plugins: [
viteStaticCopy({
targets: [
{
src: normalizePath(
path.resolve(__dirname, "node_modules/file-icons/icons") + "/[!.]*"
),
dest: "./icons/",
}
]
})
]
}
:warning: Make sure that the "dest" is set correctly otherwise the
setCDN("/icons/");
will not work. Make sure they match.
:warning: This will copy all the icons into your
./dist/icons
directory on build and add around ~3.32 MB to it
PRs are welcome!
FAQs
File Icons for IDEs
The npm package @crabnebula/file-icons receives a total of 6 weekly downloads. As such, @crabnebula/file-icons popularity was classified as not popular.
We found that @crabnebula/file-icons demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.