general-category
Look up General_Category of Unicode character with JavaScript.
News: The package was considerably slimed down ⬇️ as of version 1.4.0 🙌
$ du -h `npm pack general-category@1.3`184K general-category-1.3.0.tgz$ du -h `npm pack general-category@1.4`24K general-category-1.4.0.tgz$ du -h `npm pack general-category@1.5`17K general-category-1.5.0.tgz
Usage
const category = ; // Just gimme character and you'll get category.; //=> 'Lu' // This module is aware of surrogate pairs.; //=> 'So' // Providing code point also works.; //=> 'Zs' // You'll get category data with latest version of Unicode by default.// You can switch it by `version` option; //=> '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 = ;; //=> 'Cn' // 'latest' version also works.const categoryLatest = ;; //=> 'So' // You can get long_name instead of an abbreviated one.; //=> 'Uppercase_Letter' // You can also get detaild information of category.; //=> { 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_Categoryoptions
[Object]:long
[Boolean]: Returns long_name instead of abbreviated form. Default isfalse
.detailed
[Boolean]: Returns detailed category information instead of plain string. Default isfalse
.version
[String | Null]: Version number to use as unicode data source. You can setnull
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 settrue
, returns object with detailed category information.