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

general-category

v1.6.0

Published

Look up General_Category of Unicode character

Downloads

40

Readme

general-category

npm version Build Status Dependency Status devDependency Status

semantic-release Commitizen friendly

Look up General_Category of Unicode character with JavaScript.

News: The package was considerably slimed down :arrow_down: as of version 1.4.0 :raised_hands:

$ du -h `npm pack [email protected]`
184K    general-category-1.3.0.tgz
$ du -h `npm pack [email protected]`
24K     general-category-1.4.0.tgz
$ du -h `npm pack [email protected]`
17K     general-category-1.5.0.tgz

Usage

const category = require('general-category');

// Just gimme character and you'll get category.
category('Å'); //=> 'Lu'

// This module is aware of surrogate pairs.
category('\u{1F600}'); //=> 'So'

// Providing code point also works.
category(0x0020); //=> 'Zs'

// You'll get category data with latest version of Unicode by default.
// You can switch it by `version` option
category('\u{1F600}', {version: '6.0.0'}); //=> 'Cn'

// If you are only interested in the specific version of Unicode,
// you can require the module with limited data loaded.
const category3_2_0 = require('general-category/3.2.0');
category3_2_0('\u{1F600}'); //=> 'Cn'

// 'latest' version also works.
const categoryLatest = require('general-category/latest');
categoryLatest('\u{1F600}'); //=> 'So'

// You can get long_name instead of an abbreviated one.
category('Ä', {long: true}); //=> 'Uppercase_Letter'

// You can also get detaild information of category.
category('Ä', {detailed: true}); //=> { large: 'L', small: 'Lu' }

API

This module exposes single function category(character[, options]).

  • character [String | Number]: Character or code point to look up for General_Category
  • options [Object]:
    • long [Boolean]: Returns long_name instead of abbreviated form. Default is false.
    • detailed [Boolean]: Returns detailed category information instead of plain string. Default is false.
    • version [String | Null]: Version number to use as unicode data source. You can set null to use latest version included. These versions are derived from node-unicode-data and currently all available versions are:
      • 1.1.5
      • 2.0.14
      • 2.1.2
      • 2.1.5
      • 2.1.8
      • 2.1.9
      • 3.0.0
      • 3.0.1
      • 3.1.0
      • 3.2.0
      • 4.0.0
      • 4.0.1
      • 4.1.0
      • 5.0.0
      • 5.1.0
      • 5.2.0
      • 6.0.0
      • 6.1.0
      • 6.2.0
      • 6.3.0
      • 7.0.0
      • 8.0.0
      • 9.0.0
  • return [String | Object]: General_Category of the given character. If options.detailed is set true, returns object with detailed category information.