1
0
Fork 0

JavaScript code cleanup and optimizations

* removed all console statements

  * sorting script: no longer creating functions within the loop

  * aosp2tt9: fixed incorrect usage of a global variable

  * injest-words: fixed a non-strict comparison

  * remove-repeating-words: commented out the case-sensitive search function, as it may be going out of use
This commit is contained in:
sspanak 2024-03-27 17:04:09 +02:00 committed by Dimo Karaivanov
parent 1c900139a2
commit 8a971ea15e
9 changed files with 70 additions and 65 deletions

View file

@ -1,13 +1,14 @@
const { basename } = require('path');
const { createReadStream, existsSync } = require('fs');
const { createInterface } = require('readline');
const { print, printError } = require('./_printers.js');
function printHelp() {
console.log(`Usage ${basename(process.argv[1])} LOCALE word-list.txt`);
console.log('Searches for compound words with that also exsit as separate words and removes the compound variants.');
console.log('For example, "fly-by" will be removed, if the word list contains both "fly" and "by".')
console.log('LOCALE could be any valid JS locale, for exmaple: en, en-US, etc...')
print(`Usage ${basename(process.argv[1])} LOCALE word-list.txt`);
print('Searches for compound words with that also exsit as separate words and removes the compound variants.');
print('For example, "fly-by" will be removed, if the word list contains both "fly" and "by".')
print('LOCALE could be any valid JS locale, for exmaple: en, en-US, etc...')
}
@ -18,7 +19,7 @@ function validateInput() {
}
if (!existsSync(process.argv[3])) {
console.error(`Failure! Could not find word list file "${process.argv[3]}."`);
printError(`Failure! Could not find word list file "${process.argv[3]}".`);
process.exit(2);
}
@ -32,7 +33,7 @@ function validateInput() {
function printWords(wordList) {
if (wordList instanceof Set) {
wordList.forEach(w => console.log(w));
wordList.forEach(w => print(w));
}
}
@ -109,4 +110,4 @@ async function work({ fileName, locale, separator }) {
/** main **/
work(validateInput())
.then(words => printWords(words))
.catch(e => console.error(e));
.catch(e => printError(e));