UNPKG

shevchenko

Version:

JavaScript library for declension of Ukrainian anthroponyms

33 lines (30 loc) 850 B
/** * @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} */ 'use strict'; const VOWEL_PATTERN = /[аоуеиіяюєї]/gi; /** * Returns a number of syllables in a given word. */ function countSyllables(word) { const matches = word.match(VOWEL_PATTERN); if (matches == null) { return 0; } return matches.length; } /** * Returns true if a given word is a monosyllable. * Returns false otherwise. */ function isMonosyllable(word) { return countSyllables(word) === 1; } exports.VOWEL_PATTERN = VOWEL_PATTERN; exports.isMonosyllable = isMonosyllable;