npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fastld-js

v1.0.1

Published

Simple and Performant Language detection library using 2,3,4-gram matching. Pure JS, zero dependencies, offline-capable. Supports 130+ languages.

Readme

(FastLd-JS) fastld-js

A fast, lightweight, and high-performance language detection library based on n-gram matching (2-, 3-, and 4-grams). Written in pure JavaScript with zero dependencies, works completely offline. Supports 130+ languages.

GitHub: https://github.com/zendtay-studio/fastld-js

⚡ Performance

This library is optimized for speed. Using an in-memory indexed search (PURE_MATCH_ARRAY), detection takes only fractions of a millisecond per text, making it ideal for real-time and batch processing where analytical performance is critical.

⚠️ Known Limitation

Short texts (e.g., one or two words) do not work reliably. The detection relies on statistical frequency of n-grams, so a medium to long text is required for accurate results.


📦 Installation

npm install fastld-js

🚀 API Usage

All functions are exposed from the main index.js file.

1. Detect main language (detect)

Returns the most probable language, or a limited number of top results.

const { detect } = require('fastld-js');

const text = "La familia salió de viaje hacia la playa el fin de semana pasado.";

// Get the most likely language
const result = detect(text);
console.log(result);
/*
Output:
{
  code: 'es',
  code2: 'spa',
  name: 'Spanish',
  accuracy: 0.8543,
  matches: 120,
  total: 140
}
*/

// Get top N results by passing a number
const top3 = detect(text, 3);
console.log(top3); // Array of the 3 most probable languages

2. Get full breakdown (detectAll)

Analyzes the text and returns a sorted array (highest to lowest accuracy) of all supported languages that had matches.

const { detectAll } = require('fastld-js');

const text = "The family went on a trip to the beach last weekend.";
const allLanguages = detectAll(text);

console.log(allLanguages[0]);
/*
Output:
{
  code: 'en',
  code2: 'eng',
  name: 'English',
  accuracy: 0.8912,
  matches: 135,
  total: 151
}
*/

3. Database information (getDatabaseInfo)

Returns technical details about the internally loaded data model.

const { getDatabaseInfo } = require('fastld-js');

const dbInfo = getDatabaseInfo();
console.log(dbInfo);

Current technical specifications:

  • Type: PURE_MATCH_ARRAY
  • Languages: 130
  • Total n-grams: 254,497
  • Config: 2, 3, 4-grams, top 9000 per language

📄 License

Apache 2.0 © ZendTay Studio