shevchenko
Version:
JavaScript library for declension of Ukrainian anthroponyms
37 lines (34 loc) • 1.5 kB
JavaScript
/**
* @file JavaScript library for declension of Ukrainian anthroponyms
* @module shevchenko
* @version 3.2.2
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
* @license MIT
* @copyright 2017-2026 Oleksandr Tolochko <shevchenko-js@tooleks.com>
* @see {@link git+https://github.com/tooleks/shevchenko-js.git}
*/
;
class AnthroponymInflector {
constructor(givenNameInflector, patronymicNameInflector, familyNameInflector) {
this.givenNameInflector = givenNameInflector;
this.patronymicNameInflector = patronymicNameInflector;
this.familyNameInflector = familyNameInflector;
}
/**
* Inflects the anthroponym in the given grammatical case.
*/
async inflect(anthroponym, gender, grammaticalCase) {
const inflectedAnthroponym = {};
if (anthroponym.givenName != null) {
inflectedAnthroponym.givenName = await this.givenNameInflector.inflect(anthroponym.givenName, gender, grammaticalCase);
}
if (anthroponym.patronymicName != null) {
inflectedAnthroponym.patronymicName = await this.patronymicNameInflector.inflect(anthroponym.patronymicName, gender, grammaticalCase);
}
if (anthroponym.familyName != null) {
inflectedAnthroponym.familyName = await this.familyNameInflector.inflect(anthroponym.familyName, gender, grammaticalCase);
}
return inflectedAnthroponym;
}
}
exports.AnthroponymInflector = AnthroponymInflector;