Skip to content

Commit eb523ff

Browse files
committed
Modernize codebase
1 parent ecf43b1 commit eb523ff

42 files changed

Lines changed: 1152 additions & 1112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@ To use the generated data, simply install one of [the npm modules generated by t
88

99
```js
1010
// Get an array of all code points with the `White_Space` property:
11-
const codePoints = require('@unicode/unicode-6.3.0/Binary_Property/White_Space/code-points');
11+
import whiteSpaceCodePoints from '@unicode/unicode-6.3.0/Binary_Property/White_Space/code-points.mjs';
1212
// Get an array of strings (containing one symbol each) in the `Lu` category:
13-
const symbols = require('@unicode/unicode-6.3.0/General_Category/Uppercase_Letter/symbols');
13+
import luSymbols from '@unicode/unicode-6.3.0/General_Category/Uppercase_Letter/symbols.mjs';
1414
// Get a regular expression that matches any symbol in the `Aegean Numbers` block:
15-
const regex = require('@unicode/unicode-6.3.0/Block/Aegean_Numbers/regex');
15+
import aegeanNumbersRegex from '@unicode/unicode-6.3.0/Block/Aegean_Numbers/regex.mjs';
1616
// Get an array of all code points in the `Egyptian_Hieroglyphs` script:
17-
const hieroglyphs = require('@unicode/unicode-6.3.0/Script/Egyptian_Hieroglyphs/code-points');
17+
import hieroglyphs from '@unicode/unicode-6.3.0/Script/Egyptian_Hieroglyphs/code-points.mjs';
1818
// Get the canonical category a given code point belongs to:
1919
// (Note: U+0041 is LATIN CAPITAL LETTER A)
20-
const category = require('@unicode/unicode-6.3.0/General_Category').get(0x41);
20+
import generalCategory from '@unicode/unicode-6.3.0/General_Category/index.mjs';
21+
const category = generalCategory.get(0x41);
2122
// Get an array of all code points with a given bidi class:
22-
const lre = require('@unicode/unicode-6.3.0/Bidi_Class/Left_To_Right_Embedding/code-points');
23+
import lre from '@unicode/unicode-6.3.0/Bidi_Class/Left_To_Right_Embedding/code-points.mjs';
2324
// Get the directionality of a given code point:
24-
const directionality = require('@unicode/unicode-6.3.0/Bidi_Class').get(0x41);
25+
import bidiClass from '@unicode/unicode-6.3.0/Bidi_Class/index.mjs';
26+
const directionality = bidiClass.get(0x41);
2527
// What glyph is the mirror image of `«` (U+00AB)?
26-
const mirrored = require('@unicode/unicode-6.3.0/Bidi_Mirroring_Glyph').get(
27-
0xab,
28-
);
28+
import bidiMirroringGlyph from '@unicode/unicode-6.3.0/Bidi_Mirroring_Glyph/index.mjs';
29+
const mirrored = bidiMirroringGlyph.get(0xab);
2930
// Get a regular expression that matches all opening brackets:
30-
const openingBrackets = require('@unicode/unicode-6.3.0/Bidi_Paired_Bracket_Type/Open/regex');
31+
import openingBrackets from '@unicode/unicode-6.3.0/Bidi_Paired_Bracket_Type/Open/regex.mjs';
3132
// …you get the idea.
3233
```
3334

@@ -68,10 +69,10 @@ For more information, see the README for the package you’re interested in. [He
6869
- [_@unicode/unicode-16.0.0_](https://npmjs.org/package/@unicode/unicode-16.0.0#readme) ([repository](https://github.com/node-unicode/unicode-16.0.0#readme))
6970
- [_@unicode/unicode-17.0.0_](https://npmjs.org/package/@unicode/unicode-17.0.0#readme) ([repository](https://github.com/node-unicode/unicode-17.0.0#readme))
7071

71-
Note that these READMEs are auto-generated by this script, too – they describe all the data that is available for that particular Unicode version. To programmatically get this list of available categories, scripts, script extensions, blocks, and properties for a given Unicode version, just `require` the main module for that version:
72+
Note that these READMEs are auto-generated by this script, too – they describe all the data that is available for that particular Unicode version. To programmatically get this list of available categories, scripts, script extensions, blocks, and properties for a given Unicode version, just `import` the main module for that version:
7273

7374
```js
74-
> require('unicode-6.3.0');
75+
> import unicode630 from '@unicode/unicode-6.3.0';
7576
{
7677
'Binary_Property': [
7778
'Alphabetic', 'Any', 'ASCII', 'ASCII_Hex_Digit', 'Assigned', …
@@ -119,9 +120,9 @@ This clones all the generated repositories to your local `output` folder. You ca
119120

120121
## Generating the data
121122

122-
`npm run download` (re-)downloads the Unicode source files for all the Unicode versions defined in `data/resources.js`, saving them in the `data` folder.
123+
`npm run download` (re-)downloads the Unicode source files for all the Unicode versions defined in `data/resources.mjs`, saving them in the `data` folder.
123124

124-
`npm run build` generates data for all the Unicode versions defined in `data/resources.js`. This may take a few minutes… The regular expressions are generated using [Regenerate](https://mths.be/regenerate).
125+
`npm run build` generates data for all the Unicode versions defined in `data/resources.mjs`. This may take a few minutes… The regular expressions are generated using [Regenerate](https://mths.be/regenerate).
125126

126127
## Testing
127128

‎clone-repos.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd "$(dirname "${BASH_SOURCE}")";
44

5-
VERSIONS=$(node scripts/log-versions.js);
5+
VERSIONS=$(node scripts/log-versions.mjs);
66

77
mkdir -p output;
88
cd output;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,4 +1014,4 @@ const resources = [
10141014
},
10151015
];
10161016

1017-
module.exports = resources;
1017+
export default resources;

‎index.js‎

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)