shevchenko 3.1.0-alpha.4 → 3.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/cjs/anthroponym-declension/anthroponym-inflector.js +3 -1
  2. package/dist/cjs/anthroponym-declension/bootstrap.js +3 -1
  3. package/dist/cjs/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +2 -2
  4. package/dist/cjs/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +1 -1
  5. package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +3 -1
  6. package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-classifer.js +7 -4
  7. package/dist/cjs/anthroponym-declension/family-name-classifier/model-bundle-loader.js +8 -6
  8. package/dist/cjs/anthroponym-declension/family-name-classifier/model-config.js +3 -1
  9. package/dist/cjs/anthroponym-declension/family-name-classifier/word-transformer.js +3 -1
  10. package/dist/cjs/anthroponym-declension/family-name-inflector.js +3 -1
  11. package/dist/cjs/anthroponym-declension/given-name-inflector.js +3 -1
  12. package/dist/cjs/anthroponym-declension/name-inflector.js +3 -1
  13. package/dist/cjs/anthroponym-declension/patronymic-name-inflector.js +3 -1
  14. package/dist/cjs/extension.js +11 -1
  15. package/dist/cjs/gender-detection/detect-gender.js +3 -1
  16. package/dist/cjs/gender-detection/given-names-genders.json.js +1 -1
  17. package/dist/cjs/index.js +6 -4
  18. package/dist/cjs/input-validation.js +29 -41
  19. package/dist/cjs/language/alphabet.js +3 -1
  20. package/dist/cjs/language/grammatical-case.js +3 -1
  21. package/dist/cjs/language/grammatical-gender.js +3 -1
  22. package/dist/cjs/language/letter-case.js +3 -1
  23. package/dist/cjs/language/linguistics.js +3 -1
  24. package/dist/cjs/language/word-class.js +3 -1
  25. package/dist/cjs/shevchenko.js +6 -4
  26. package/dist/cjs/word-declension/append-command-runner.js +3 -1
  27. package/dist/cjs/word-declension/bootstrap.js +3 -1
  28. package/dist/cjs/word-declension/command-runner-factory.js +3 -1
  29. package/dist/cjs/word-declension/declension-rule-inflector.js +3 -1
  30. package/dist/cjs/word-declension/declension-types.js +3 -1
  31. package/dist/cjs/word-declension/replace-command-runner.js +3 -1
  32. package/dist/cjs/word-declension/rules/artifacts/declension-rules.json.js +85 -1
  33. package/dist/cjs/word-declension/word-inflector.js +3 -1
  34. package/dist/es/anthroponym-declension/anthroponym-inflector.js +1 -1
  35. package/dist/es/anthroponym-declension/bootstrap.js +1 -1
  36. package/dist/es/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +1 -1
  37. package/dist/es/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +1 -1
  38. package/dist/es/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +1 -1
  39. package/dist/es/anthroponym-declension/family-name-classifier/family-name-classifer.js +1 -1
  40. package/dist/es/anthroponym-declension/family-name-classifier/model-bundle-loader.js +1 -1
  41. package/dist/es/anthroponym-declension/family-name-classifier/model-config.js +1 -1
  42. package/dist/es/anthroponym-declension/family-name-classifier/word-transformer.js +1 -1
  43. package/dist/es/anthroponym-declension/family-name-inflector.js +1 -1
  44. package/dist/es/anthroponym-declension/given-name-inflector.js +1 -1
  45. package/dist/es/anthroponym-declension/name-inflector.js +1 -1
  46. package/dist/es/anthroponym-declension/patronymic-name-inflector.js +1 -1
  47. package/dist/es/extension.d.ts +2 -2
  48. package/dist/es/extension.js +9 -2
  49. package/dist/es/gender-detection/detect-gender.js +1 -1
  50. package/dist/es/gender-detection/given-names-genders.json.js +1 -1
  51. package/dist/es/index.js +1 -1
  52. package/dist/es/input-validation.d.ts +2 -2
  53. package/dist/es/input-validation.js +27 -41
  54. package/dist/es/language/alphabet.js +1 -1
  55. package/dist/es/language/grammatical-case.js +1 -1
  56. package/dist/es/language/grammatical-gender.js +1 -1
  57. package/dist/es/language/letter-case.js +1 -1
  58. package/dist/es/language/linguistics.js +1 -1
  59. package/dist/es/language/word-class.js +1 -1
  60. package/dist/es/shevchenko.js +3 -2
  61. package/dist/es/word-declension/append-command-runner.js +1 -1
  62. package/dist/es/word-declension/bootstrap.js +1 -1
  63. package/dist/es/word-declension/command-runner-factory.js +1 -1
  64. package/dist/es/word-declension/declension-rule-inflector.js +1 -1
  65. package/dist/es/word-declension/declension-types.js +1 -1
  66. package/dist/es/word-declension/replace-command-runner.js +1 -1
  67. package/dist/es/word-declension/rules/artifacts/declension-rules.json.js +85 -1
  68. package/dist/es/word-declension/word-inflector.js +1 -1
  69. package/dist/umd/shevchenko.min.js +386 -305
  70. package/package.json +3 -2
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  var declensionRules = require('./rules/artifacts/declension-rules.json.js');
13
15
  var wordInflector$1 = require('./word-inflector.js');
14
16
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  var appendCommandRunner = require('./append-command-runner.js');
13
15
  var declensionTypes = require('./declension-types.js');
14
16
  var replaceCommandRunner = require('./replace-command-runner.js');
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  require('../language/alphabet.js');
13
15
  require('../language/word-class.js');
14
16
  require('../language/grammatical-case.js');
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  require('../language/alphabet.js');
13
15
  require('../language/word-class.js');
14
16
  require('../language/grammatical-case.js');
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  class ReplaceCommandRunner {
13
15
  constructor(command) {
14
16
  this.command = command;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -4557,6 +4557,90 @@ var declensionRules = [
4557
4557
  ]
4558
4558
  }
4559
4559
  },
4560
+ {
4561
+ description: "друга відміна / чоловічий рід / м'яка група / на -екар, -етар, -зар, -ухар",
4562
+ examples: [
4563
+ "пекар",
4564
+ "решетар",
4565
+ "кожухар",
4566
+ "кобзар"
4567
+ ],
4568
+ wordClass: "noun",
4569
+ gender: [
4570
+ "masculine"
4571
+ ],
4572
+ priority: 3,
4573
+ applicationType: [
4574
+ ],
4575
+ pattern: {
4576
+ find: "(екар|етар|зар|ухар)(?<!гузар)$",
4577
+ modify: "(.{1})$"
4578
+ },
4579
+ grammaticalCases: {
4580
+ nominative: [
4581
+ ],
4582
+ genitive: [
4583
+ {
4584
+ "0": {
4585
+ action: "append",
4586
+ value: "я"
4587
+ }
4588
+ }
4589
+ ],
4590
+ dative: [
4591
+ {
4592
+ "0": {
4593
+ action: "append",
4594
+ value: "ю"
4595
+ }
4596
+ },
4597
+ {
4598
+ "0": {
4599
+ action: "append",
4600
+ value: "еві"
4601
+ }
4602
+ }
4603
+ ],
4604
+ accusative: [
4605
+ {
4606
+ "0": {
4607
+ action: "append",
4608
+ value: "я"
4609
+ }
4610
+ }
4611
+ ],
4612
+ ablative: [
4613
+ {
4614
+ "0": {
4615
+ action: "append",
4616
+ value: "ем"
4617
+ }
4618
+ }
4619
+ ],
4620
+ locative: [
4621
+ {
4622
+ "0": {
4623
+ action: "append",
4624
+ value: "еві"
4625
+ }
4626
+ },
4627
+ {
4628
+ "0": {
4629
+ action: "append",
4630
+ value: "і"
4631
+ }
4632
+ }
4633
+ ],
4634
+ vocative: [
4635
+ {
4636
+ "0": {
4637
+ action: "append",
4638
+ value: "ю"
4639
+ }
4640
+ }
4641
+ ]
4642
+ }
4643
+ },
4560
4644
  {
4561
4645
  description: "друга відміна / чоловічий рід / тверда група / на -кіш",
4562
4646
  examples: [
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -9,6 +9,8 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ Object.defineProperty(exports, '__esModule', { value: true });
13
+
12
14
  var declensionRuleInflector = require('./declension-rule-inflector.js');
13
15
 
14
16
  class WordInflector {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  import { DeclensionInput, DeclensionOutput } from './contracts';
2
2
  import { GrammaticalCase } from './language';
3
3
  import { WordInflector } from './word-declension';
4
- type FieldName = keyof Omit<DeclensionInput, 'gender'>;
4
+ export type FieldName = keyof Omit<DeclensionInput, 'gender'>;
5
5
  export type AfterInflectHook = <T extends DeclensionInput>(grammaticalCase: GrammaticalCase, input: T) => Promise<DeclensionOutput<T>>;
6
6
  export type ShevchenkoExtension = {
7
7
  fieldNames: FieldName[];
@@ -12,5 +12,5 @@ export type ExtensionContext = {
12
12
  wordInflector: WordInflector;
13
13
  };
14
14
  export declare function registerExtension(extensionFactory: ExtensionFactory): void;
15
+ export declare function getCustomFieldNames(): FieldName[];
15
16
  export declare function afterInflect<T extends DeclensionInput>(grammaticalCase: GrammaticalCase, input: T): Promise<DeclensionOutput<T>>;
16
- export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -14,6 +14,13 @@ function registerExtension(extensionFactory) {
14
14
  const extension = extensionFactory({ wordInflector });
15
15
  registeredExtensions.push(extension);
16
16
  }
17
+ function getCustomFieldNames() {
18
+ const fieldNames = [];
19
+ for (const extension of registeredExtensions) {
20
+ fieldNames.push(...extension.fieldNames);
21
+ }
22
+ return fieldNames;
23
+ }
17
24
  async function afterInflect(grammaticalCase, input) {
18
25
  var _a;
19
26
  const output = {};
@@ -26,4 +33,4 @@ async function afterInflect(grammaticalCase, input) {
26
33
  return output;
27
34
  }
28
35
 
29
- export { afterInflect, registerExtension };
36
+ export { afterInflect, getCustomFieldNames, registerExtension };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
package/dist/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -6,10 +6,10 @@ export declare class InputValidationError extends TypeError {
6
6
  *
7
7
  * @throws {InputValidationError}
8
8
  */
9
- export declare function validateDeclensionInput(value: unknown): asserts value is DeclensionInput;
9
+ export declare function validateDeclensionInput(input: unknown): asserts input is DeclensionInput;
10
10
  /**
11
11
  * Validates if a given value is a valid input for gender detection.
12
12
  *
13
13
  * @throws {InputValidationError}
14
14
  */
15
- export declare function validateGenderDetectionInput(value: unknown): asserts value is GenderDetectionInput;
15
+ export declare function validateGenderDetectionInput(input: unknown): asserts input is GenderDetectionInput;
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
8
8
  * @see {@link git+https://github.com/tooleks/shevchenko-js.git}
9
9
  */
10
+ import { getCustomFieldNames } from './extension.js';
10
11
  import './language/alphabet.js';
11
12
  import './language/word-class.js';
12
13
  import './language/grammatical-case.js';
@@ -14,31 +15,30 @@ import { GrammaticalGender } from './language/grammatical-gender.js';
14
15
 
15
16
  class InputValidationError extends TypeError {
16
17
  }
18
+ const fieldNames = ['givenName', 'patronymicName', 'familyName'];
17
19
  /**
18
20
  * Validates if a given value is a valid input for declension.
19
21
  *
20
22
  * @throws {InputValidationError}
21
23
  */
22
- function validateDeclensionInput(value) {
23
- if (!isObject(value)) {
24
+ function validateDeclensionInput(input) {
25
+ if (!isObject(input)) {
24
26
  throw new InputValidationError('The input type must be an object.');
25
27
  }
26
- if (!isIn(value.gender, Object.values(GrammaticalGender))) {
27
- throw new InputValidationError(`The "gender" parameter must be one of the following: "${GrammaticalGender.MASCULINE}", "${GrammaticalGender.FEMININE}".`);
28
+ const isGenderValid = Object.values(GrammaticalGender).includes(input.gender);
29
+ if (!isGenderValid) {
30
+ throw new InputValidationError(`The "gender" parameter must be one of the following:` +
31
+ ` "${Object.values(GrammaticalGender).join('", "')}".`);
28
32
  }
29
- if (!isDefined(value.givenName) &&
30
- !isDefined(value.patronymicName) &&
31
- !isDefined(value.familyName)) {
32
- throw new InputValidationError('At least one of the following parameters must present: "givenName", "patronymicName", "familyName".');
33
+ const mergedFieldNames = [...fieldNames, ...getCustomFieldNames()];
34
+ const hasFields = mergedFieldNames.some((fieldName) => fieldName in input && typeof input[fieldName] !== 'undefined');
35
+ if (!hasFields) {
36
+ throw new InputValidationError(`At least one of the following parameters must present: "${mergedFieldNames.join('", "')}".`);
33
37
  }
34
- if (isDefined(value.givenName) && !isString(value.givenName)) {
35
- throw new InputValidationError('The "givenName" parameter must be a string.');
36
- }
37
- if (isDefined(value.patronymicName) && !isString(value.patronymicName)) {
38
- throw new InputValidationError('The "patronymicName" parameter must be a string.');
39
- }
40
- if (isDefined(value.familyName) && !isString(value.familyName)) {
41
- throw new InputValidationError('The "familyName" parameter must be a string.');
38
+ for (const fieldName of mergedFieldNames) {
39
+ if (fieldName in input && typeof input[fieldName] !== 'string') {
40
+ throw new InputValidationError(`The "${fieldName}" parameter must be a string.`);
41
+ }
42
42
  }
43
43
  }
44
44
  /**
@@ -46,36 +46,22 @@ function validateDeclensionInput(value) {
46
46
  *
47
47
  * @throws {InputValidationError}
48
48
  */
49
- function validateGenderDetectionInput(value) {
50
- if (!isObject(value)) {
49
+ function validateGenderDetectionInput(input) {
50
+ if (!isObject(input)) {
51
51
  throw new InputValidationError('The input type must be an object.');
52
52
  }
53
- if (!isDefined(value.givenName) &&
54
- !isDefined(value.patronymicName) &&
55
- !isDefined(value.familyName)) {
56
- throw new InputValidationError('At least one of the following parameters must present: "givenName", "patronymicName", "familyName".');
57
- }
58
- if (isDefined(value.givenName) && !isString(value.givenName)) {
59
- throw new InputValidationError('The "givenName" parameter must be a string.');
60
- }
61
- if (isDefined(value.patronymicName) && !isString(value.patronymicName)) {
62
- throw new InputValidationError('The "patronymicName" parameter must be a string.');
53
+ const hasFields = fieldNames.some((fieldName) => fieldName in input && typeof input[fieldName] !== 'undefined');
54
+ if (!hasFields) {
55
+ throw new InputValidationError(`At least one of the following parameters must present: "${fieldNames.join('", "')}".`);
63
56
  }
64
- if (isDefined(value.familyName) && !isString(value.familyName)) {
65
- throw new InputValidationError('The "familyName" parameter must be a string.');
57
+ for (const fieldName of fieldNames) {
58
+ if (fieldName in input && typeof input[fieldName] !== 'string') {
59
+ throw new InputValidationError(`The "${fieldName}" parameter must be a string.`);
60
+ }
66
61
  }
67
62
  }
68
- function isDefined(value) {
69
- return typeof value !== 'undefined';
70
- }
71
63
  function isObject(value) {
72
- return value != null && typeof value === 'object';
73
- }
74
- function isString(value) {
75
- return typeof value === 'string';
76
- }
77
- function isIn(value, values) {
78
- return values.includes(value);
64
+ return typeof value === 'object' && value != null;
79
65
  }
80
66
 
81
67
  export { InputValidationError, validateDeclensionInput, validateGenderDetectionInput };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -16,6 +16,7 @@ export { InputValidationError } from './input-validation.js';
16
16
  import './language/alphabet.js';
17
17
  export { WordClass } from './language/word-class.js';
18
18
  import { GrammaticalCase } from './language/grammatical-case.js';
19
+ export { GrammaticalCase } from './language/grammatical-case.js';
19
20
  export { GrammaticalGender } from './language/grammatical-gender.js';
20
21
  import './word-declension/declension-types.js';
21
22
 
@@ -168,4 +169,4 @@ async function detectGender(input) {
168
169
  return detectGender$1(input);
169
170
  }
170
171
 
171
- export { GrammaticalCase, detectGender, inAblative, inAccusative, inDative, inGenitive, inLocative, inNominative, inVocative };
172
+ export { detectGender, inAblative, inAccusative, inDative, inGenitive, inLocative, inNominative, inVocative };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file JavaScript library for declension of Ukrainian anthroponyms
3
3
  * @module shevchenko
4
- * @version 3.1.0-alpha.3
4
+ * @version 3.1.0-alpha.6
5
5
  * @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
6
6
  * @license MIT
7
7
  * @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>