unicode-data

JavaScript-compatible Unicode data generator. Arrays of code points, arrays of symbols, and regular expressions for every Unicode version’s categories, scripts, blocks, and properties.

npm install unicode-data
8 downloads in the last month

node-unicode-data Build status Dependency status

JavaScript-compatible Unicode data generator. Arrays of code points, arrays of symbols, and regular expressions for every Unicode version’s categories, scripts, blocks, and properties — neatly packaged into a separate npm package per Unicode version.

Using the data in your scripts

To use the generated data, simply install one of the npm modules generated by this script. Separate packages are available for each Unicode version. This allows you to do stuff like:

// Get an array of all code points with the `White_Space` property:
var codePoints = require('unicode-6.3.0/properties/White_Space/code-points');
// Get an array of strings (containing one symbol each) in the `Lu` category:
var symbols = require('unicode-6.3.0/categories/Lu/symbols');
// Get a regular expression that matches any symbol in the `Aegean Numbers` block:
var regex = require('unicode-6.3.0/blocks/Aegean Numbers/regex');
// Get an array of all code points in the `Egyptian_Hieroglyphs` script:
var hieroglyphs = require('unicode-6.3.0/scripts/Egyptian_Hieroglyphs/code-points');
// …you get the idea.

For more information, see the README for the package you’re interested in. Here’s the full list of npm packages generated by this script:

Note that these READMEs are auto-generated by this script, too – they describe all the data that is available for that particular Unicode version.

Generating the data

npm run-script download (re-)downloads the Unicode source files for all the Unicode versions defined in data/resources.js, saving them in the data folder.

npm run-script generate generates data for categories, scripts, blocks, and properties for all the Unicode versions defined in data/resources.js. This may take a few minutes… In total, roughly 1.5 GB of data is generated. The regular expressions are generated using Regenerate, and Punycode.js is used to convert code point arrays into arrays of symbols.

Testing

npm test generates the data for the oldest and latest available Unicode version. This is a good way to test changes to the generator scripts before running npm run-script generate.

npm run-script cover generates the code coverage report.

Author

twitter/mathias
Mathias Bynens

License

This module is available under the MIT license.

npm loves you