-
Notifications
You must be signed in to change notification settings - Fork 0
/
sortDict.js
34 lines (26 loc) · 1017 Bytes
/
sortDict.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs');
process.chdir(__dirname);
console.log('Reading dictionary.txt');
let dictionary = fs
.readFileSync('../dictionary/dictionary.txt', { encoding: 'UTF8' })
.replace('\r', '')
.split('\n');
let ocDictionary = fs
.readFileSync('../dictionary/opencorekeys.txt', { encoding: 'UTF8' })
.replace('\r', '')
.split('\n');
dictionary = dictionary.filter((string) => string != '');
ocDictionary = ocDictionary.filter((string) => string != '');
dictionary = dictionary.filter(
(string, index) => dictionary.indexOf(string) == index,
);
ocDictionary = ocDictionary.filter(
(string, index) => ocDictionary.indexOf(string) == index,
);
dictionary = dictionary.filter((string) => !ocDictionary.includes(string));
console.log('Sorting...');
dictionary.sort();
ocDictionary.sort();
console.log('Writing dictionary.txt');
fs.writeFileSync('../dictionary/dictionary.txt', dictionary.join('\n'));
fs.writeFileSync('../dictionary/opencorekeys.txt', ocDictionary.join('\n'));