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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eldr

v1.1.0

Published

Fast and accurate natural language detector based on eld by Nito TM.

Readme

ELDR - Efficient Language Detector, Refactored

npm version License: Apache-2.0

A fast and accurate natural language detector for TypeScript/JavaScript, refactored from Nito-ELD to provide better TypeScript support and avoid top-level await for easier bundling.

Features

  • 🚀 Fast: Optimized for performance with efficient n-gram processing
  • 🎯 Accurate: High accuracy language detection across 60 supported languages
  • 📦 TypeScript: Full TypeScript support with exported type definitions
  • 🔧 Flexible: Multiple size variants for different use cases
  • 🌐 Universal: Works in Node.js and browser environments
  • 📱 Lightweight: Choose from different package sizes based on your needs

Installation

npm install eldr

or

yarn add eldr

Quick Start

import { eldr } from "eldr";

const result = eldr.detect("Hola, cómo te llamas?");
console.log(result.iso639_1); // "es"
console.log(result.languageName); // "Spanish"
console.log(result.isReliable()); // true
console.log(result.getScores()); // { es: 0.5289, et: 0.2093, ... }

Usage

Basic Usage

import { eldr } from "eldr";

// Detect language
const detected = eldr.detect("Hello, how are you?");
console.log(detected.iso639_1); // "en"
console.log(detected.languageName); // "English"
console.log(detected.isReliable()); // true

Different Package Sizes

Choose the package size that fits your needs:

// Extra Small (fastest, least accurate)
import { extraSmall as eldr } from "eldr";

// Small
import { small as eldr } from "eldr";

// Medium (default - best balance)
import { medium as eldr } from "eldr";

// Large (most accurate, largest size)
import { large as eldr } from "eldr";

Advanced Usage

import { eldr } from "eldr";

// Enable text cleaning (removes URLs, emails, etc.)
eldr.cleanText(true);

const result = eldr.detect(
  "Check out https://example.com and email me at [email protected]"
);

// Get detailed information
console.log(result.getScores()); // Detailed scores for all languages
console.log(result.isReliable()); // Whether the detection is reliable
console.log(eldr.info()); // Package information and supported languages

Result Object

The detect() method returns a LanguageResult object with the following properties:

  • iso639_1: ISO 639-1 language code (e.g., "en", "es", "fr")
  • languageName: Full language name (e.g., "English", "Spanish", "French")
  • language: Alias for iso639_1 (backwards compatibility)
  • isReliable(): Returns true if the detection is considered reliable
  • getScores(): Returns detailed scores for all languages

Supported Languages

ELDR supports 60 languages with ISO 639-1 codes:

ISO 639-1 Codes: 'am', 'ar', 'az', 'be', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'gu', 'he', 'hi', 'hr', 'hu', 'hy', 'is', 'it', 'ja', 'ka', 'kn', 'ko', 'ku', 'lo', 'lt', 'lv', 'ml', 'mr', 'ms', 'nl', 'no', 'or', 'pa', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'ta', 'te', 'th', 'tl', 'tr', 'uk', 'ur', 'vi', 'yo', 'zh'

Full Language Names: Amharic, Arabic, Azerbaijani (Latin), Belarusian, Bulgarian, Bengali, Catalan, Czech, Danish, German, Greek, English, Spanish, Estonian, Basque, Persian, Finnish, French, Gujarati, Hebrew, Hindi, Croatian, Hungarian, Armenian, Icelandic, Italian, Japanese, Georgian, Kannada, Korean, Kurdish (Arabic), Lao, Lithuanian, Latvian, Malayalam, Marathi, Malay (Latin), Dutch, Norwegian, Oriya, Punjabi, Polish, Portuguese, Romanian, Russian, Slovak, Slovene, Albanian, Serbian (Cyrillic), Swedish, Tamil, Telugu, Thai, Tagalog, Turkish, Ukrainian, Urdu, Vietnamese, Yoruba, Chinese

API Reference

ELDR Class

Methods

  • detect(text: string): LanguageResult - Detect the language of the given text
  • cleanText(doClean: boolean): void - Enable/disable text cleaning (removes URLs, emails, etc.)
  • info(): object - Get package information and supported languages

LanguageResult Class

Properties

  • iso639_1: string - ISO 639-1 language code
  • languageName: string - Full language name
  • language: string - Alias for iso639_1 (backwards compatibility)

Methods

  • isReliable(): boolean - Returns true if the detection is considered reliable
  • getScores(): Record<string, number> - Returns detailed scores for all languages

Performance

ELDR is optimized for performance:

  • Processes text in chunks to handle large inputs efficiently
  • Uses optimized n-gram matching algorithms
  • Provides different package sizes for different performance/accuracy trade-offs
  • Text processing is limited to the first 1000 characters for optimal performance

Browser Support

ELDR works in all modern browsers that support:

  • ES2021 features
  • TypedArrays
  • String methods (codePointAt, etc.)

Node.js Support

Requires Node.js 16.0.0 or higher.

Development

Building

npm run build

Testing

npm test

Linting

npm run lint

License

Licensed under the Apache License 2.0. See LICENSE for details.

Credits

Related Projects

  • ELD - Original Efficient Language Detector
  • franc - Another language detection library
  • language-detector - Alternative language detection library

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

v1.1.0

  • Initial release with TypeScript support
  • Refactored from original ELD library
  • Added multiple package size variants
  • Improved bundling compatibility