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

micromark-util-character

v2.1.1

Published

micromark utility to handle character codes

Downloads

38,365,396

Readme

micromark-util-character

Build Coverage Downloads Size Sponsors Backers Chat

micromark utility to handle character codes.

Contents

What is this?

This package exposes algorithms to check whether characters match groups.

When should I use this?

This package might be useful when you are making your own micromark extensions.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install micromark-util-character

In Deno with esm.sh:

import * as character from 'https://esm.sh/micromark-util-character@1'

In browsers with esm.sh:

<script type="module">
  import * as character from 'https://esm.sh/micromark-util-character@1?bundle'
</script>

Use

import {asciiAlpha} from 'micromark-util-character'

console.log(asciiAlpha(64)) // false
console.log(asciiAlpha(65)) // true

API

This module exports the identifiers asciiAlpha, asciiAlphanumeric, asciiAtext, asciiControl, asciiDigit, asciiHexDigit, asciiPunctuation, markdownLineEnding, markdownLineEndingOrSpace, markdownSpace, unicodePunctuation, unicodeWhitespace. There is no default export.

asciiAlpha(code)

Check whether the character code represents an ASCII alpha (a through z, case insensitive).

An ASCII alpha is an ASCII upper alpha or ASCII lower alpha.

An ASCII upper alpha is a character in the inclusive range U+0041 (A) to U+005A (Z).

An ASCII lower alpha is a character in the inclusive range U+0061 (a) to U+007A (z).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiAlphanumeric(code)

Check whether the character code represents an ASCII alphanumeric (a through z, case insensitive, or 0 through 9).

An ASCII alphanumeric is an ASCII digit (see asciiDigit) or ASCII alpha (see asciiAlpha).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiAtext(code)

Check whether the character code represents an ASCII atext.

atext is an ASCII alphanumeric (see asciiAlphanumeric), or a character in the inclusive ranges U+0023 NUMBER SIGN (#) to U+0027 APOSTROPHE ('), U+002A ASTERISK (*), U+002B PLUS SIGN (+), U+002D DASH (-), U+002F SLASH (/), U+003D EQUALS TO (=), U+003F QUESTION MARK (?), U+005E CARET (^) to U+0060 GRAVE ACCENT (`), or U+007B LEFT CURLY BRACE ({) to U+007E TILDE (~) ([RFC5322]).

See [RFC5322]:
Internet Message Format.
P. Resnick.
IETF.

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiControl(code)

Check whether a character code is an ASCII control character.

An ASCII control is a character in the inclusive range U+0000 NULL (NUL) to U+001F (US), or U+007F (DEL).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiDigit(code)

Check whether the character code represents an ASCII digit (0 through 9).

An ASCII digit is a character in the inclusive range U+0030 (0) to U+0039 (9).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiHexDigit(code)

Check whether the character code represents an ASCII hex digit (a through f, case insensitive, or 0 through 9).

An ASCII hex digit is an ASCII digit (see asciiDigit), ASCII upper hex digit, or an ASCII lower hex digit.

An ASCII upper hex digit is a character in the inclusive range U+0041 (A) to U+0046 (F).

An ASCII lower hex digit is a character in the inclusive range U+0061 (a) to U+0066 (f).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

asciiPunctuation(code)

Check whether the character code represents ASCII punctuation.

An ASCII punctuation is a character in the inclusive ranges U+0021 EXCLAMATION MARK (!) to U+002F SLASH (/), U+003A COLON (:) to U+0040 AT SIGN (@), U+005B LEFT SQUARE BRACKET ([) to U+0060 GRAVE ACCENT (`), or U+007B LEFT CURLY BRACE ({) to U+007E TILDE (~).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

markdownLineEnding(code)

Check whether a character code is a markdown line ending.

A markdown line ending is the virtual characters M-0003 CARRIAGE RETURN LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).

In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) are replaced by these virtual characters depending on whether they occurred together.

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

markdownLineEndingOrSpace(code)

Check whether a character code is a markdown line ending (see markdownLineEnding) or markdown space (see markdownSpace).

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

markdownSpace(code)

Check whether a character code is a markdown space.

A markdown space is the concrete character U+0020 SPACE (SP) and the virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).

In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL SPACE (VS) characters, depending on the column at which the tab occurred.

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

unicodePunctuation(code)

Check whether the character code represents Unicode punctuation.

A Unicode punctuation is a character in the Unicode Pc (Punctuation, Connector), Pd (Punctuation, Dash), Pe (Punctuation, Close), Pf (Punctuation, Final quote), Pi (Punctuation, Initial quote), Po (Punctuation, Other), or Ps (Punctuation, Open) categories, or an ASCII punctuation (see asciiPunctuation) ([UNICODE]).

See [UNICODE]:
The Unicode Standard.
Unicode Consortium.

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

unicodeWhitespace(code)

Check whether the character code represents Unicode whitespace.

Note that this does handle micromark specific markdown whitespace characters. See markdownLineEndingOrSpace to check that.

A Unicode whitespace is a character in the Unicode Zs (Separator, Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), U+000C (FF), or U+000D CARRIAGE RETURN (CR) ([UNICODE]).

See [UNICODE]:
The Unicode Standard.
Unicode Consortium.

Parameters
  • code (Code) — code
Returns

Whether it matches (boolean).

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, micromark-util-character@2, compatible with Node.js 16. This package works with micromark@3.

Security

This package is safe. See security.md in micromark/.github for how to submit a security report.

Contribute

See contributing.md in micromark/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer