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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@notevenaneko/whatlang-node

v1.0.1

Published

Use whatlang-rs in your NodeJS applications.

Downloads

176

Readme

whatlang-node

https://github.com/Cattttttttt/whatlang-node/actions

NodeJS binding of whatlang-rs

Usage

Install

npm install @notevenaneko/whatlang-node

or

yarn add @notevenaneko/whatlang-node

or

pnpm add @notevenaneko/whatlang-node

Detect language

import { detect, LangCode, LangCodeISO6391 } from '@notevenaneko/whatlang-node'

const info = detect(englishInput)

info.lang.code === LangCode.Eng
info.lang.codeISO6391 === LangCodeISO6391.En
info.lang.name === 'English'
info.lang.engName === 'English'

info.script.name === 'Latin'

compareFloat(info.confidence, 1) === true

info.isReliable === true

Allowlist and denylist

import { Detector, LangCode } from '@notevenaneko/whatlang-node'

const normalDetector = new Detector()

const chineseDetector = Detector.withAllowlist([LangCode.Cmn /* or LangCodeISO6391.Zh in ISO639-1 */])

normalDetector.detectLang(englishInput).code === LangCode.Eng

chineseDetector.detectLang(englishInput) === null

const noZhDetector = Detector.withDenylist([LangCode.Cmn /* or LangCodeISO6391.Zh in ISO639-1 */])

normalDetector.detectLang(chineseInput).code === LangCode.Cmn

noZhDetector.detectLang(chineseInput).code === LangCode.Jpn

Support matrix

Operating Systems

| | node14 | node16 | node18 | | ---------------- | ------ | ------ | ------ | | Windows x64 | ✓ | ✓ | ✓ | | Windows x32 | ✓ | ✓ | ✓ | | Windows arm64 | ✓ | ✓ | ✓ | | macOS x64 | ✓ | ✓ | ✓ | | macOS arm64 | ✓ | ✓ | ✓ | | Linux x64 gnu | ✓ | ✓ | ✓ | | Linux x64 musl | ✓ | ✓ | ✓ | | Linux arm gnu | ✓ | ✓ | ✓ | | Linux arm64 gnu | ✓ | ✓ | ✓ | | Linux arm64 musl | ✓ | ✓ | ✓ | | Android arm64 | ✓ | ✓ | ✓ | | Android armv7 | ✓ | ✓ | ✓ | | FreeBSD x64 | ✓ | ✓ | ✓ |

Bench

Name: Apple M1
Vendor String: Apple
Vendor ID: VendorUnknown
PhysicalCores: 8
Threads Per Core: 1
Logical Cores: 8
CPU Family 458787763 Model: 0 Stepping: 0
Features: AESARM,ASIMD,ASIMDDP,ASIMDHP,ASIMDRDM,ATOMICS,CRC32,DCPOP,FCMA,FP,FPHP,GPA,JSCVT,LRCPC,PMULL,SHA1,SHA2,SHA3,SHA512
Microarchitecture level: 0
Cacheline bytes: 128
L1 Instruction Cache: 131072 bytes
L1 Data Cache: 65536 bytes
L2 Cache: 4194304 bytes
L3 Cache: -1 bytes

Running "Detect language" suite...
Progress: 100%

  languagedetect:
    10 799 ops/s, ±3.38%   | slowest, 38.05% slower

  whatlang-node:
    17 432 ops/s, ±0.97%   | fastest

  @notevenaneko/whatlang-node:
    17 294 ops/s, ±0.58%   | 0.79% slower

Finished 3 cases!
  Fastest: whatlang-node
  Slowest: languagedetect

TODO

  • [ ] Complete Script enum and constructor
  • [ ] documentation