Skip to content

Commit

Permalink
Lints code base.
Browse files Browse the repository at this point in the history
  • Loading branch information
zorkow committed Apr 25, 2022
1 parent 41f125a commit 9d89b43
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 62 deletions.
2 changes: 1 addition & 1 deletion ts/common/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Engine {
*/
public mode: EngineConst.Mode = EngineConst.Mode.SYNC;

public init: boolean = true;
public init = true;

/**
* Maps domains to comparators.
Expand Down
3 changes: 2 additions & 1 deletion ts/common/engine_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export async function setup(feature: { [key: string]: boolean | string }) {
if (engine.init) {
EnginePromise.promises['init'] = new Promise((res, _rej) => {
setTimeout(() => {
res('init');}, 10)
res('init');
}, 10);
});
engine.init = false;
return EnginePromise.get();
Expand Down
4 changes: 1 addition & 3 deletions ts/common/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export async function engineReady(): Promise<any> {
*/
export const localeLoader = standardLoader;


// Naming convention:
// Input is either an XML expression as a string or from a file.
// Output:
Expand Down Expand Up @@ -408,8 +407,7 @@ export const localePath = FileUtil.localePath;

// Check here for custom method!
if (SystemExternal.documentSupported) {
setupEngine({ mode: EngineConst.Mode.HTTP }).then(() =>
setupEngine({}));
setupEngine({ mode: EngineConst.Mode.HTTP }).then(() => setupEngine({}));
} else {
setupEngine({ mode: EngineConst.Mode.SYNC }).then(() =>
setupEngine({ mode: EngineConst.Mode.ASYNC })
Expand Down
2 changes: 1 addition & 1 deletion ts/common/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Variables {
*
* @param loc The locale in question.
* @param def A default locale.
* @return The existing locale. The default is returned if `loc` does not
* @returns The existing locale. The default is returned if `loc` does not
* exist. There is no further check on `def`, however!
*/
public static ensureLocale(loc: string, def: string): string {
Expand Down
4 changes: 3 additions & 1 deletion ts/l10n/l10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ function setSubiso(msg: Locale) {
*/
export function getLocale(): Locale {
const locale = Variables.ensureLocale(
Engine.getInstance().locale, Engine.getInstance().defaultLocale);
Engine.getInstance().locale,
Engine.getInstance().defaultLocale
);
Engine.getInstance().locale = locale;
return locales[locale]();
}
Expand Down
7 changes: 4 additions & 3 deletions ts/l10n/locales/locale_da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ function create(): Locale {
loc.NUMBERS = NUMBERS;
loc.FUNCTIONS.radicalNestDepth = nestingToString;
loc.FUNCTIONS.fontRegexp = (font) => {
return (font === loc.ALPHABETS.capPrefix['default']) ?
RegExp('^' + font + ' ') : RegExp(' ' + font + '$');
}
return font === loc.ALPHABETS.capPrefix['default']
? RegExp('^' + font + ' ')
: RegExp(' ' + font + '$');
};
loc.ALPHABETS.combiner = tr.Combiners.postfixCombiner;
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
return loc;
Expand Down
21 changes: 13 additions & 8 deletions ts/l10n/numbers/numbers_da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function onePrefix_(num: string, mill = false): string {
* Translates a number of up to twelve digits into a string representation.
*
* @param num The number to translate.
* @param ordinal Are we computing an ordinal?
* @returns The string representation of that number.
*/
function hundredsToWords_(num: number, ordinal = false): string {
Expand All @@ -52,9 +53,9 @@ function hundredsToWords_(num: number, ordinal = false): string {
if (ones) {
str += ones;
} else {
const tens = ordinal ?
NUMBERS.special.tensOrdinals[Math.floor(n / 10)] :
NUMBERS.tens[Math.floor(n / 10)];
const tens = ordinal
? NUMBERS.special.tensOrdinals[Math.floor(n / 10)]
: NUMBERS.tens[Math.floor(n / 10)];
ones = NUMBERS.ones[n % 10];
str += ones ? onePrefix_(ones) + 'og' + tens : tens;
}
Expand All @@ -66,6 +67,7 @@ function hundredsToWords_(num: number, ordinal = false): string {
* Translates a number of up to twelve digits into a string representation.
*
* @param num The number to translate.
* @param ordinal Are we computing an ordinal?
* @returns The string representation of that number.
*/
function numberToWords(num: number, ordinal = false): string {
Expand All @@ -84,14 +86,17 @@ function numberToWords(num: number, ordinal = false): string {
if (pos) {
const large = NUMBERS.large[pos];
// If this is million or above take care of the plural.
const plural =
hundreds > 1 ? 'er' : '';
str = onePrefix_(hund, pos <= 1) + ' ' + large + plural +
(str ? ' og ' : '') + str;
const plural = hundreds > 1 ? 'er' : '';
str =
onePrefix_(hund, pos <= 1) +
' ' +
large +
plural +
(str ? ' og ' : '') +
str;
} else {
str = onePrefix_(hund) + str;
}

}
num = Math.floor(num / 1000);
pos++;
Expand Down
8 changes: 5 additions & 3 deletions ts/l10n/numbers/numbers_sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ function hundredsToWords_(num: number): string {
* Translates a number of up to twelve digits into a string representation.
*
* @param num The number to translate.
* @param ordinal Are we computing an ordinal?
* @returns The string representation of that number.
*/
function numberToWords(num: number, ordinal: boolean = false): string {
function numberToWords(num: number, ordinal = false): string {
if (num === 0) {
return NUMBERS.zero;
}
Expand All @@ -67,11 +68,12 @@ function numberToWords(num: number, ordinal: boolean = false): string {
// Case 2: hundreds === 1 and pos > 1, space, no translate
// Case 3: space and translate
const large = NUMBERS.large[pos];
const plural = (hundreds > 1 && pos > 1 && !ordinal) ? 'er' : '';
const plural = hundreds > 1 && pos > 1 && !ordinal ? 'er' : '';
str =
(pos === 1 && hundreds === 1
? ''
: (pos > 1 && hundreds === 1 ? 'en' : hundredsToWords_(num % 1000)) + (pos > 1 ? ' ' : '')) +
: (pos > 1 && hundreds === 1 ? 'en' : hundredsToWords_(num % 1000)) +
(pos > 1 ? ' ' : '')) +
(pos ? large + plural + (pos > 1 ? ' ' : '') : '') +
str;
}
Expand Down
3 changes: 1 addition & 2 deletions ts/speech_rules/clearspeak_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import * as SpeechRules from './speech_rules';
*/
export function ClearspeakRules() {
// Basic English
SpeechRules.addStore(
DynamicCstr.BASE_LOCALE + '.speech.clearspeak', '', {
SpeechRules.addStore(DynamicCstr.BASE_LOCALE + '.speech.clearspeak', '', {
CTFpauseSeparator: StoreUtil.pauseSeparator,
CTFnodeCounter: ClearspeakUtil.nodeCounter,
CTFcontentIterator: StoreUtil.contentIterator,
Expand Down
6 changes: 2 additions & 4 deletions ts/speech_rules/math_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ let _init = false;
*
* @param locale The locale to be loaded. Defaults to current locale of the
* engine.
*
* @returns Promise that resolves once locale is loaded.
*/
export async function loadLocale(locale = Engine.getInstance().locale) {
Expand All @@ -73,9 +72,9 @@ export async function loadLocale(locale = Engine.getInstance().locale) {
_init = true;
}
return EnginePromise.promises[DynamicCstr.BASE_LOCALE].then(async () => {
let defLoc = Engine.getInstance().defaultLocale;
const defLoc = Engine.getInstance().defaultLocale;
if (defLoc) {
_loadLocale(defLoc)
_loadLocale(defLoc);
return EnginePromise.promises[defLoc].then(async () => {
_loadLocale(locale);
return EnginePromise.promises[locale];
Expand Down Expand Up @@ -114,7 +113,6 @@ function loadMethod() {
return standardLoader();
}


/**
* @returns The standard load method for the given mode. This is exported as
* fall back method.
Expand Down
35 changes: 20 additions & 15 deletions ts/speech_rules/mathspeak_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import * as UnitUtil from './unit_util';
*/
export function MathspeakRules() {
// Basic English
SpeechRules.addStore(
DynamicCstr.BASE_LOCALE + '.speech.mathspeak', '', {
SpeechRules.addStore(DynamicCstr.BASE_LOCALE + '.speech.mathspeak', '', {
CQFspaceoutNumber: MathspeakUtil.spaceoutNumber,

CQFspaceoutIdentifier: MathspeakUtil.spaceoutIdentifier,
Expand Down Expand Up @@ -101,20 +100,26 @@ export function MathspeakRules() {

// Spanish
SpeechRules.addStore(
'es.speech.mathspeak', DynamicCstr.BASE_LOCALE + '.speech.mathspeak', {
CTFunitMultipliers: UnitUtil.unitMultipliers,
CQFoneLeft: UnitUtil.oneLeft
});
'es.speech.mathspeak',
DynamicCstr.BASE_LOCALE + '.speech.mathspeak',
{
CTFunitMultipliers: UnitUtil.unitMultipliers,
CQFoneLeft: UnitUtil.oneLeft
}
);

// French
SpeechRules.addStore(
'fr.speech.mathspeak', DynamicCstr.BASE_LOCALE + '.speech.mathspeak', {
CSFbaselineVerbose: MathspeakFrenchUtil.baselineVerbose,
CSFbaselineBrief: MathspeakFrenchUtil.baselineBrief,
// Tensor specific:
CSFleftsuperscriptVerbose: MathspeakFrenchUtil.leftSuperscriptVerbose,
CSFleftsubscriptVerbose: MathspeakFrenchUtil.leftSubscriptVerbose,
CSFleftsuperscriptBrief: MathspeakFrenchUtil.leftSuperscriptBrief,
CSFleftsubscriptBrief: MathspeakFrenchUtil.leftSubscriptBrief
});
'fr.speech.mathspeak',
DynamicCstr.BASE_LOCALE + '.speech.mathspeak',
{
CSFbaselineVerbose: MathspeakFrenchUtil.baselineVerbose,
CSFbaselineBrief: MathspeakFrenchUtil.baselineBrief,
// Tensor specific:
CSFleftsuperscriptVerbose: MathspeakFrenchUtil.leftSuperscriptVerbose,
CSFleftsubscriptVerbose: MathspeakFrenchUtil.leftSubscriptVerbose,
CSFleftsuperscriptBrief: MathspeakFrenchUtil.leftSuperscriptBrief,
CSFleftsubscriptBrief: MathspeakFrenchUtil.leftSubscriptBrief
}
);
}
37 changes: 20 additions & 17 deletions ts/speech_rules/other_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,28 @@ export function OtherRules() {
export function BrailleRules() {
// Basic Nemeth
SpeechRules.addStore(
'nemeth.braille.default', DynamicCstr.BASE_LOCALE + '.speech.mathspeak', {
CSFopenFraction: NemethUtil.openingFraction,
CSFcloseFraction: NemethUtil.closingFraction,
CSFoverFraction: NemethUtil.overFraction,
'nemeth.braille.default',
DynamicCstr.BASE_LOCALE + '.speech.mathspeak',
{
CSFopenFraction: NemethUtil.openingFraction,
CSFcloseFraction: NemethUtil.closingFraction,
CSFoverFraction: NemethUtil.overFraction,

CSFoverBevFraction: NemethUtil.overBevelledFraction,
// Radical function.
CSFopenRadical: NemethUtil.openingRadical,
CSFcloseRadical: NemethUtil.closingRadical,
CSFoverBevFraction: NemethUtil.overBevelledFraction,
// Radical function.
CSFopenRadical: NemethUtil.openingRadical,
CSFcloseRadical: NemethUtil.closingRadical,

CSFindexRadical: NemethUtil.indexRadical,
CSFsubscript: MathspeakUtil.subscriptVerbose,
CSFsuperscript: MathspeakUtil.superscriptVerbose,
CSFindexRadical: NemethUtil.indexRadical,
CSFsubscript: MathspeakUtil.subscriptVerbose,
CSFsuperscript: MathspeakUtil.superscriptVerbose,

CSFbaseline: MathspeakUtil.baselineVerbose,
CSFbaseline: MathspeakUtil.baselineVerbose,

CGFtensorRules: (st: SpeechRuleStore) =>
MathspeakUtil.generateTensorRules(st, false),
CTFrelationIterator: NemethUtil.relationIterator,
CTFimplicitIterator: NemethUtil.implicitIterator
});
CGFtensorRules: (st: SpeechRuleStore) =>
MathspeakUtil.generateTensorRules(st, false),
CTFrelationIterator: NemethUtil.relationIterator,
CTFimplicitIterator: NemethUtil.implicitIterator
}
);
}
4 changes: 1 addition & 3 deletions ts/speech_rules/speech_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export function getStore(
funcStore.get(
[DynamicCstr.DEFAULT_VALUES[Axis.LOCALE], modality, domain].join('.')
) ||
funcStore.get(
[DynamicCstr.BASE_LOCALE, modality, domain].join('.')
) ||
funcStore.get([DynamicCstr.BASE_LOCALE, modality, domain].join('.')) ||
{}
);
}

0 comments on commit 9d89b43

Please sign in to comment.