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

@bearz/chars

v0.1.0

Published

A simple library for working with characters and Unicode in JavaScript.

Downloads

1,244

Readme

@bearz/chars

Overview

The chars library provides functions for working with characters found in other standard libraries or frameworks such as isSpace, isLetter, isUpper, isDigit, etc.

The module will handle characters outside latin and ascii such as Cyrillic or Greek characters. The chars library is heavily based on golang's unicode module.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io

A list of other modules can be found at github.com/bearz-io/js

Usage

import { 
    isUpperAt, 
    isLowerAt, 
    isDigit, 
    isAscii, 
    isLatin1, 
    isSpaceAt,
    equalFold
} from "@bearz/chars";

const str = "Hello, World 123";
console.log(isUpperAt(str, 0)); // true
console.log(isUpperAt(str, 1)); // false
console.log(isLowerAt(str, 1)); // false
console.log(isDigit(str, 1)); // false 
console.log(isDigit(str, 14)); // true

const left = "Ꙏ".codePointAt(0)
const right = "ꙏ".codePointAt(0)
console.log(equalFold(left, right)); // true

console.log(isAsciiAt("⇼", 0)); // false
console.log(isAsciiAt(str, 0)); // true
console.log(isLatin1At("⇼", 0)); // false

const str2 = " \n\r\t\f"
console.log(isSpaceAt(str2, 0)); // true
console.log(isSpaceAt(str2, 1)); // true
console.log(isSpaceAt(str2, 2)); // true
console.log(isSpaceAt(str2, 3)); // true

Functions

The char module provides functions common character functions:

  • equalFold - true when two characters are equal using case insensitivity.
  • isAscii - true when character is ascii.
  • isChar - true when a number value is a valid character.
  • isControl - true when a character is a control character.
  • isDigit - true when a character is a digit.
  • isLatin - true when a character is in the latin charset.
  • isLetterOrDigit - true when a character is a letter or digit.
  • isLetter - true when a charater is a letter.
  • isLower - true when a character is a lower case letter.
  • isPunc - true when a character is a punction mark.
  • isSpace - true when a character is a space character.\n \r\t\f.
  • isSymbol - true when a character is a symbol.
  • isUpper - true when a character is uppercase.
  • simpleFold - when a character has a lower or higher character, fold will flip them.
  • toLower - converts a character to its lowercase counterpart, if applicable.
  • toUpper - converts a character to its uppercase counterpart, if applicable.

Constants

export const CHAR_UPPERCASE_A = 65; /* A */
export const CHAR_LOWERCASE_A = 97; /* a */
export const CHAR_UPPERCASE_Z = 90; /* Z */
export const CHAR_LOWERCASE_Z = 122; /* z */
// Non-alphabetic chars.
export const CHAR_DOT = 46; /* . */
export const CHAR_FORWARD_SLASH = 47; /* / */
export const CHAR_BACKWARD_SLASH = 92; /* \ */
export const CHAR_VERTICAL_LINE = 124; /* | */
export const CHAR_COLON = 58; /* : */
export const CHAR_QUESTION_MARK = 63; /* ? */
export const CHAR_UNDERSCORE = 95; /* _ */
export const CHAR_LINE_FEED = 10; /* \n */
export const CHAR_CARRIAGE_RETURN = 13; /* \r */
export const CHAR_TAB = 9; /* \t */
export const CHAR_FORM_FEED = 12; /* \f */
export const CHAR_EXCLAMATION_MARK = 33; /* ! */
export const CHAR_HASH = 35; /* # */
export const CHAR_SPACE = 32; /*   */
export const CHAR_NO_BREAK_SPACE = 160; /* \u00A0 */
export const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279; /* \uFEFF */
export const CHAR_LEFT_SQUARE_BRACKET = 91; /* [ */
export const CHAR_RIGHT_SQUARE_BRACKET = 93; /* ] */
export const CHAR_LEFT_ANGLE_BRACKET = 60; /* < */
export const CHAR_RIGHT_ANGLE_BRACKET = 62; /* > */
export const CHAR_LEFT_CURLY_BRACKET = 123; /* { */
export const CHAR_RIGHT_CURLY_BRACKET = 125; /* } */
export const CHAR_HYPHEN_MINUS = 45; /* - */
export const CHAR_PLUS = 43; /* + */
export const CHAR_DOUBLE_QUOTE = 34; /* " */
export const CHAR_SINGLE_QUOTE = 39; /* ' */
export const CHAR_PERCENT = 37; /* % */
export const CHAR_SEMICOLON = 59; /* ; */
export const CHAR_CIRCUMFLEX_ACCENT = 94; /* ^ */
export const CHAR_GRAVE_ACCENT = 96; /* ` */
export const CHAR_AT = 64; /* @ */
export const CHAR_AMPERSAND = 38; /* & */
export const CHAR_TILDA = 126; /* ~ */
export const CHAR_DOLLAR = 36; /* $ */
export const CHAR_VERTICAL_TAB = 11; /* \v */
export const CHAR_ASTERISK = 42; /* * */
export const CHAR_COMMA = 44; /* , */
/**
 * Equal character (`=`) code (61).
 */
export const CHAR_EQUAL = 61; /* = */
// Digits
export const CHAR_0 = 48; /* 0 */
export const CHAR_9 = 57; /* 9 */
export const MAX_RUNE = 0x10FFFF;

License

MIT License