node-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 — 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 = ;// Get an array of strings (containing one symbol each) in the `Lu` category:var symbols = ;// Get a regular expression that matches any symbol in the `Aegean Numbers` block:var regex = ;// Get an array of all code points in the `Egyptian_Hieroglyphs` script:var hieroglyphs = ;// …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:
- unicode-1.1.5
- unicode-2.0.14
- unicode-2.1.2
- unicode-2.1.5
- unicode-2.1.8
- unicode-2.1.9
- unicode-3.0.0
- unicode-3.0.1
- unicode-3.1.0
- unicode-3.2.0
- unicode-4.0.0
- unicode-4.0.1
- unicode-4.1.0
- unicode-5.0.0
- unicode-5.1.0
- unicode-5.2.0
- unicode-6.0.0
- unicode-6.1.0
- unicode-6.2.0
- unicode-6.3.0
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
Mathias Bynens |
License
This module is available under the MIT license.