cspell-trie 9.4.0 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/app.js +9 -7
  2. package/package.json +3 -3
package/dist/app.js CHANGED
@@ -30,7 +30,7 @@ export async function run(program, argv) {
30
30
  notify('Create Trie', !!outputFile);
31
31
  const pOutputStream = createWriteStream(outputFile);
32
32
  notify(`Generating...`, !!outputFile);
33
- const lines = await fileToLines(filename);
33
+ const lines = (await readTextFile(filename)).split('\n');
34
34
  const toLower = lowerCase ? (a) => a.toLowerCase() : (a) => a;
35
35
  const wordsRx = lines
36
36
  .map(toLower)
@@ -53,9 +53,9 @@ export async function run(program, argv) {
53
53
  const { output: outputFile } = options;
54
54
  notify('Reading Trie', !!outputFile);
55
55
  const pOutputStream = createWriteStream(outputFile);
56
- const lines = await fileToLines(filename);
57
- const root = Trie.importTrie(lines);
58
- const words = genSequence(Trie.iteratorTrieWords(root));
56
+ const data = await readFile(filename);
57
+ const trie = Trie.decodeTrie(data);
58
+ const words = genSequence(trie.words());
59
59
  const outputStream = await pOutputStream;
60
60
  return new Promise((resolve) => {
61
61
  stream.Readable.from(words.map((a) => a + '\n'))
@@ -65,10 +65,12 @@ export async function run(program, argv) {
65
65
  });
66
66
  return program.parseAsync(argv);
67
67
  }
68
- async function fileToLines(filename) {
68
+ async function readFile(filename) {
69
69
  const buffer = await fsp.readFile(filename);
70
- const file = (/\.gz$/.test(filename) ? zlib.gunzipSync(buffer) : buffer).toString(UTF8);
71
- return genSequence(file.split(/\r?\n/));
70
+ return /\.gz$/.test(filename) ? zlib.gunzipSync(buffer) : buffer;
71
+ }
72
+ async function readTextFile(filename) {
73
+ return new TextDecoder(UTF8).decode(await readFile(filename));
72
74
  }
73
75
  function createWriteStream(filename) {
74
76
  return !filename
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "9.4.0",
7
+ "version": "9.6.0",
8
8
  "description": "Trie Data Structure reader for cspell",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -46,11 +46,11 @@
46
46
  "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-trie#readme",
47
47
  "dependencies": {
48
48
  "commander": "^14.0.2",
49
- "cspell-trie-lib": "9.4.0",
49
+ "cspell-trie-lib": "9.6.0",
50
50
  "gensequence": "^8.0.8"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=20"
54
54
  },
55
- "gitHead": "12dba3d8b880384d1401c765cb2186647f5a266f"
55
+ "gitHead": "163793ddf2a0ad90bc7c90351698a106003297af"
56
56
  }