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

char-info

v0.3.2

Published

Unicode character information library. For both server-side and client-side use.

Downloads

18,849

Readme

char-info

Travic CI Codecov NPM

API Documentation

A library that gives you information about individual Unicode characters. It also provides a list of Unicode groupings and their names, including lists of categories, blocks, and scripts. This is also reflected in the library's type definition files.

You can use for stuff like:

  1. Find out what language a character is in, such as Greek (α), Latin (a), Hebrew (א), and so on.
  2. Whether it's a kind of punctuation, digit, letter, emoji, spacing mark, or something else
  3. What Unicode character block it inhabits
  4. If it's upper-case or lower-case

The library only supports characters in the BMP. There are no plans to expanding it beyond the BMP.

In addition, the library provides basic ASCII character indicator functions, such as isLetter, isUpper, and so forth. These have really simple implementations and don't have the overhead of the Unicode indicators.

The library comes bundled with Unicode character information tables that originally came from the Unicode Character Database. This data can make bundles with the library being quite heavy. To counteract this, the library is built to leverage "tree shaking" or dead code elimination, which is used in all modern bundlers. Provided you only import the members you'll use, only some of the data will end up in your bundle. For example, if you just import the ASCII character indicators your bundle won't contain any Unicode data at all.

Enabling dead code elimination may require switching to ES2015 native modules. You'll need to look at your bundler's documentation for more information.

Imports

The package has three paths you can import from:

  1. char-info/ascii, which contains indicator functions for ASCII characters and character codes.
  2. char-info/unicode, which contain the special Unicode character indicators.
  3. char-info, which re-exports everything.

If you're using a properly configured bundler, you can import what you need from char-info and still take advantage of tree shaking.

Usage - ASCII indicators

import {isLetter, isUpper, isUpperCode} from "char-info"

assert.isTrue(isLetter("a"));
assert.isTrue(isUpper("A"));
assert.isTrue(isUpperCode("A"));

// You can also do it like this:
import * as AsciiInfo from "char-info/ascii";

assert.isTrue(AsciiInfo.isLetterCode("a".charCodeAt(0));

Usage - Unicode Indicators

Unicode indicators work a bit differently, and aren't just plain functions. Instead, each indicator has two members, char and code, for testing characters (in the form of strings) and character codes, respectively.

import {uniIsLetter, uniIsDigit} from "char-info";

assert.isTrue(uniIsLetter.char("א"));
assert.isTrue(uniIsDigit.char("٩"));