Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(NumberingSystems).forEach(k => {
const sys = NumberingSystems[k];
if (sys._type !== 'algorithmic') {
return;
}
if (sys._rules.indexOf('/SpelloutRules') === -1) {
return;
}
const parts = sys._rules.split('/');
const tag = LanguageResolver.resolve(parts[0]);
const id = `${tag.language()}-${tag.script()}`;
if (!this.core.includes(id)) {
this.core.push(id);
}
// Map numbering systems to a spellout locale id
const set = this.systems.get(id) || [];
set.push(k);
this.systems.set(id, set);
});
const res: Map = new Map();
const ids: string[] = [];
for (const file of files) {
const p = path.join(dir, file);
const data = JSON.parse(fs.readFileSync(p, { encoding: 'utf-8' })) as JSONRoot;
if (!data.SpelloutRules && !data.OrdinalRules) {
continue;
}
const { name } = path.parse(file);
let id = name;
if (name !== 'root') {
// compact each tag to language-script with region if specified
const tag = parseLanguageTag(name);
const max = LanguageResolver.resolve(name);
id = `${max.language()}-${max.script()}`;
if (tag.hasRegion()) {
id = `${id}-${max.region()}`;
}
}
res.set(id, data);
ids.push(id);
}
res.forEach((_, id) => this.populate(res, id));
// Fill in the locales that have no RBNF mapping.
for (const locale of availableLocales()) {
const { tag } = locale;
const id = `${tag.language()}-${tag.script()}`;
if (res.has(id)) {
Object.keys(supp.NumberingSystems).forEach(k => {
const o = supp.NumberingSystems[k];
if (o._type === 'numeric') {
const v: string[] = Array.from(o._digits);
numeric += ` ${k}: [${escape(increasing(v) ? v.slice(0, 1) : v)}],\n`;
} else if (o._type === 'algorithmic') {
const v = o._rules;
let parts = ['root', v];
if (v.indexOf('/SpelloutRules') !== -1) {
const tmp = v.split('/');
const tag = LanguageResolver.resolve(tmp[0]);
const id = `${tag.language()}-${tag.script()}`;
parts = [id, tmp[2]];
}
algorithmic += ` ${k}: [${parts.map(p => `'${p}'`).join(', ')}],\n`;
}
});
const getLocale = (id: string): Locale => ({ id, tag: LanguageResolver.resolve(id) });