UNPKG

shevchenko

Version:

JavaScript library for declension of Ukrainian anthroponyms

34 lines (31 loc) 1.1 kB
/** * @file JavaScript library for declension of Ukrainian anthroponyms * @module shevchenko * @version 3.1.4 * @author Oleksandr Tolochko <shevchenko-js@tooleks.com> * @license MIT * @copyright 2017-2025 Oleksandr Tolochko <shevchenko-js@tooleks.com> * @see {@link git+https://github.com/tooleks/shevchenko-js.git} */ import { AppendCommandRunner } from './append-command-runner.js'; import { InflectionCommandAction } from './declension-types.js'; import { ReplaceCommandRunner } from './replace-command-runner.js'; class CommandRunnerFactory { /** * Creates a new command runner for the given command. */ make(command) { switch (command.action) { case InflectionCommandAction.APPEND: { return new AppendCommandRunner(command); } case InflectionCommandAction.REPLACE: { return new ReplaceCommandRunner(command); } default: { throw new TypeError(`Invalid command action: ${command.action}.`); } } } } export { CommandRunnerFactory };