shevchenko
Version:
JavaScript library for declension of Ukrainian anthroponyms
37 lines (34 loc) • 1.25 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}
*/
import { wordInflector } from './word-declension/bootstrap.js';
const registeredExtensions = [];
function registerExtension(extensionFactory) {
const extension = extensionFactory({ wordInflector });
registeredExtensions.push(extension);
}
function getCustomFieldNames() {
const fieldNames = [];
for (const extension of registeredExtensions) {
fieldNames.push(...extension.fieldNames);
}
return fieldNames;
}
async function afterInflect(grammaticalCase, input) {
var _a;
const output = {};
for (const extension of registeredExtensions) {
const customOutput = await ((_a = extension.afterInflect) === null || _a === void 0 ? void 0 : _a.call(extension, grammaticalCase, input));
if (customOutput != null) {
Object.assign(output, customOutput);
}
}
return output;
}
export { afterInflect, getCustomFieldNames, registerExtension };