| Crates.io | linguisto |
| lib.rs | linguisto |
| version | 0.1.2 |
| created_at | 2026-01-15 09:30:34.118248+00 |
| updated_at | 2026-01-15 12:18:52.504811+00 |
| description | A high-performance code language analysis tool based on github-linguist |
| homepage | |
| repository | https://github.com/HomyeeKing/linguist |
| max_upload_size | |
| id | 2045061 |
| size | 222,578 |
Linguisto is a high-performance code language analysis tool based on github-linguist. Built with Rust and providing Node.js bindings via NAPI-RS, it quickly scans directories to count files, calculate byte sizes, and determine language percentages, while intelligently filtering out third-party dependencies and ignored files.
.gitignore, skips hidden files, and excludes vendored files (e.g., node_modules).If you have Rust installed, you can install it via Cargo:
cargo install linguisto
Or install it globally via npm:
npm install -g @homy/linguist
Install it as a dependency in your Node.js project:
npm install @homy/linguist
Run it in the current directory to see an intuitive language distribution chart (sorted by byte size by default):
linguisto
Analyze a specific directory:
linguisto /path/to/your/project
--json: Output results in JSON format.--all: Show all calculated language statistics. (Currently behaves the same as the default view, kept for compatibility.)--sort <type>: Sort results. type can be file_count (descending) or bytes (descending, default).--max-lang <number>: Maximum number of languages to display individually. Remaining languages will be grouped into "Other" (default: 6).# Get JSON stats for the current project sorted by file count
linguisto . --json --sort=file_count
You can call the API provided by @homy/linguist directly in your Node.js or TypeScript code.
const { analyzeDirectory, analyzeDirectorySync } = require('@homy/linguist');
// Asynchronous analysis (recommended for large directories)
async function run() {
const stats = await analyzeDirectory('./src');
console.log(stats);
}
run();
// Synchronous analysis
const syncStats = analyzeDirectorySync('./src');
console.log(syncStats);
This project includes a simple benchmark comparing linguisto (native Rust + NAPI) with the pure JavaScript implementation linguist-js.
The benchmark script is located at benchmark/bench.ts and can be run with:
pnpm bench
Below is a sample result on this repository (macOS, Node.js, default settings):
Running benchmark...
┌─────────┬──────────────────────┬────────────────────┬─────────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼──────────────────────┼────────────────────┼─────────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'linguist-js' │ '87352945 ± 0.86%' │ '86415417 ± 955312' │ '11 ± 0.79%' │ '12 ± 0' │ 64 │
│ 1 │ 'linguisto (native)' │ '2903259 ± 2.20%' │ '3118667 ± 52375' │ '363 ± 2.64%' │ '321 ± 5' │ 345 │
└─────────┴──────────────────────┴────────────────────┴─────────────────────┴────────────────────────┴────────────────────────┴─────────┘
From this run, linguisto (native) achieves roughly 30× higher throughput than linguist-js on this project, thanks to Rust's multi-threaded file system traversal and native execution.
(dir: string) => Promise<LanguageStat[]>Asynchronously analyzes the target directory and returns an array of language statistics.
(dir: string) => LanguageStat[]Synchronously analyzes the target directory and returns an array of language statistics.
Each statistical object contains the following fields:
| Field | Type | Description |
|---|---|---|
lang |
string |
Detected language name (e.g., "Rust", "TypeScript") |
count |
number |
Number of files for this language |
bytes |
number |
Total bytes occupied by files of this language |
ratio |
number |
Percentage in the overall project (0.0 - 1.0) |