hokey-runtime
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -18,3 +18,3 @@ import { HokeyAllMessages, HokeyLocaleMessages } from "./util.js"; | ||
localeEmoji(locale: string): string | undefined; | ||
stopWords: (ALL_MESSAGES: HokeyAllMessages) => string[]; | ||
stopWords: () => string[]; | ||
} |
import { isUnknownMessage } from "./util.js"; | ||
export class Hokey { | ||
constructor(ALL_MESSAGES, FALLBACK_DEFAULT_LANG) { | ||
this.stopWords = (ALL_MESSAGES) => { | ||
this.stopWords = () => { | ||
if (this.STOP_WORDS != null) { | ||
@@ -9,7 +9,7 @@ return this.STOP_WORDS; | ||
const stops = []; | ||
for (const locale of Object.keys(ALL_MESSAGES)) { | ||
if (ALL_MESSAGES[locale] && | ||
ALL_MESSAGES[locale].search_stop_words && | ||
!isUnknownMessage(ALL_MESSAGES[locale].search_stop_words)) { | ||
stops.push(...ALL_MESSAGES[locale].search_stop_words.split(",")); | ||
for (const locale of Object.keys(this.ALL_MESSAGES)) { | ||
if (this.ALL_MESSAGES[locale] && | ||
this.ALL_MESSAGES[locale].search_stop_words && | ||
!isUnknownMessage(this.ALL_MESSAGES[locale].search_stop_words)) { | ||
stops.push(...this.ALL_MESSAGES[locale].search_stop_words.split(",")); | ||
} | ||
@@ -64,3 +64,3 @@ } | ||
// console.log(`findFirstLocaleMatch(${JSON.stringify(locales)}) returning DEFAULT_LOCALE [${DEFAULT_LOCALE}]`) | ||
if (defaultLocale) | ||
if (defaultLocale && this.ALL_MESSAGES[defaultLocale]) | ||
return defaultLocale; | ||
@@ -73,3 +73,3 @@ if (this.ALL_MESSAGES[this.FALLBACK_DEFAULT_LANG]) | ||
} | ||
throw new Error("findFirstLocaleMatch: no languages defined in MESSAGES!"); | ||
throw new Error("findFirstLocaleNameMatch: no languages defined!"); | ||
} | ||
@@ -76,0 +76,0 @@ findFirstLocaleMatch(locales) { |
@@ -18,3 +18,3 @@ import { HokeyAllMessages, HokeyLocaleMessages } from "./util.js"; | ||
localeEmoji(locale: string): string | undefined; | ||
stopWords: (ALL_MESSAGES: HokeyAllMessages) => string[]; | ||
stopWords: () => string[]; | ||
} |
import { isUnknownMessage } from "./util.js"; | ||
export class Hokey { | ||
constructor(ALL_MESSAGES, FALLBACK_DEFAULT_LANG) { | ||
this.stopWords = (ALL_MESSAGES) => { | ||
this.stopWords = () => { | ||
if (this.STOP_WORDS != null) { | ||
@@ -9,7 +9,7 @@ return this.STOP_WORDS; | ||
const stops = []; | ||
for (const locale of Object.keys(ALL_MESSAGES)) { | ||
if (ALL_MESSAGES[locale] && | ||
ALL_MESSAGES[locale].search_stop_words && | ||
!isUnknownMessage(ALL_MESSAGES[locale].search_stop_words)) { | ||
stops.push(...ALL_MESSAGES[locale].search_stop_words.split(",")); | ||
for (const locale of Object.keys(this.ALL_MESSAGES)) { | ||
if (this.ALL_MESSAGES[locale] && | ||
this.ALL_MESSAGES[locale].search_stop_words && | ||
!isUnknownMessage(this.ALL_MESSAGES[locale].search_stop_words)) { | ||
stops.push(...this.ALL_MESSAGES[locale].search_stop_words.split(",")); | ||
} | ||
@@ -64,3 +64,3 @@ } | ||
// console.log(`findFirstLocaleMatch(${JSON.stringify(locales)}) returning DEFAULT_LOCALE [${DEFAULT_LOCALE}]`) | ||
if (defaultLocale) | ||
if (defaultLocale && this.ALL_MESSAGES[defaultLocale]) | ||
return defaultLocale; | ||
@@ -73,3 +73,3 @@ if (this.ALL_MESSAGES[this.FALLBACK_DEFAULT_LANG]) | ||
} | ||
throw new Error("findFirstLocaleMatch: no languages defined in MESSAGES!"); | ||
throw new Error("findFirstLocaleNameMatch: no languages defined!"); | ||
} | ||
@@ -76,0 +76,0 @@ findFirstLocaleMatch(locales) { |
{ | ||
"name": "hokey-runtime", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "runtime library for hokeylization", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29154