namefully 1.1.0 → 1.2.0

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 (156) hide show
  1. package/dist/example/index.js +2734 -0
  2. package/dist/lib/config.d.ts +121 -0
  3. package/dist/lib/config.js +189 -0
  4. package/dist/lib/config.js.map +1 -0
  5. package/dist/lib/constants.d.ts +4 -0
  6. package/dist/lib/constants.js +31 -0
  7. package/dist/lib/constants.js.map +1 -0
  8. package/dist/lib/error.d.ts +172 -0
  9. package/dist/lib/error.js +210 -0
  10. package/dist/lib/error.js.map +1 -0
  11. package/dist/lib/example/example.d.ts +1 -0
  12. package/dist/lib/full-name.d.ts +71 -0
  13. package/dist/lib/full-name.js +147 -0
  14. package/dist/lib/full-name.js.map +1 -0
  15. package/dist/lib/index.d.ts +16 -6
  16. package/dist/lib/index.js +29 -8
  17. package/dist/lib/index.js.map +1 -1
  18. package/dist/lib/name.d.ts +177 -0
  19. package/dist/lib/name.js +322 -0
  20. package/dist/lib/name.js.map +1 -0
  21. package/dist/lib/namefully.d.ts +285 -208
  22. package/dist/lib/namefully.js +576 -576
  23. package/dist/lib/namefully.js.map +1 -1
  24. package/dist/lib/parser.d.ts +46 -0
  25. package/dist/lib/parser.js +173 -0
  26. package/dist/lib/parser.js.map +1 -0
  27. package/dist/lib/src/config.d.ts +121 -0
  28. package/dist/lib/src/constants.d.ts +4 -0
  29. package/dist/lib/src/error.d.ts +172 -0
  30. package/dist/lib/src/full-name.d.ts +71 -0
  31. package/dist/lib/src/index.d.ts +20 -0
  32. package/dist/lib/src/name.d.ts +177 -0
  33. package/dist/lib/src/namefully.d.ts +379 -0
  34. package/dist/lib/src/parser.d.ts +46 -0
  35. package/dist/lib/src/types.d.ts +127 -0
  36. package/dist/lib/src/utils.d.ts +63 -0
  37. package/dist/lib/src/validator.d.ts +66 -0
  38. package/dist/lib/types.d.ts +127 -0
  39. package/dist/lib/types.js +181 -0
  40. package/dist/lib/types.js.map +1 -0
  41. package/dist/lib/utils.d.ts +63 -0
  42. package/dist/lib/utils.js +138 -0
  43. package/dist/lib/utils.js.map +1 -0
  44. package/dist/lib/validator.d.ts +66 -0
  45. package/dist/lib/validator.js +332 -0
  46. package/dist/lib/validator.js.map +1 -0
  47. package/dist/umd/namefully.js +2118 -2700
  48. package/dist/umd/namefully.js.map +1 -1
  49. package/dist/umd/namefully.min.js +1 -1
  50. package/dist/umd/namefully.min.js.LICENSE.txt +1 -18
  51. package/dist/umd/namefully.min.js.map +1 -1
  52. package/package.json +50 -54
  53. package/readme.md +132 -162
  54. package/changelog.md +0 -134
  55. package/dist/lib/core/constants.d.ts +0 -48
  56. package/dist/lib/core/constants.js +0 -101
  57. package/dist/lib/core/constants.js.map +0 -1
  58. package/dist/lib/core/core.d.ts +0 -17
  59. package/dist/lib/core/core.js +0 -24
  60. package/dist/lib/core/core.js.map +0 -1
  61. package/dist/lib/core/index.d.ts +0 -9
  62. package/dist/lib/core/index.js +0 -13
  63. package/dist/lib/core/index.js.map +0 -1
  64. package/dist/lib/core/parsers/array-name.parser.d.ts +0 -41
  65. package/dist/lib/core/parsers/array-name.parser.js +0 -86
  66. package/dist/lib/core/parsers/array-name.parser.js.map +0 -1
  67. package/dist/lib/core/parsers/array-string.parser.d.ts +0 -47
  68. package/dist/lib/core/parsers/array-string.parser.js +0 -95
  69. package/dist/lib/core/parsers/array-string.parser.js.map +0 -1
  70. package/dist/lib/core/parsers/index.d.ts +0 -11
  71. package/dist/lib/core/parsers/index.js +0 -11
  72. package/dist/lib/core/parsers/index.js.map +0 -1
  73. package/dist/lib/core/parsers/nama.parser.d.ts +0 -33
  74. package/dist/lib/core/parsers/nama.parser.js +0 -74
  75. package/dist/lib/core/parsers/nama.parser.js.map +0 -1
  76. package/dist/lib/core/parsers/parser.d.ts +0 -28
  77. package/dist/lib/core/parsers/parser.js +0 -3
  78. package/dist/lib/core/parsers/parser.js.map +0 -1
  79. package/dist/lib/core/parsers/string.parser.d.ts +0 -60
  80. package/dist/lib/core/parsers/string.parser.js +0 -62
  81. package/dist/lib/core/parsers/string.parser.js.map +0 -1
  82. package/dist/lib/core/utils.d.ts +0 -52
  83. package/dist/lib/core/utils.js +0 -178
  84. package/dist/lib/core/utils.js.map +0 -1
  85. package/dist/lib/models/enums.d.ts +0 -106
  86. package/dist/lib/models/enums.js +0 -114
  87. package/dist/lib/models/enums.js.map +0 -1
  88. package/dist/lib/models/firstname.d.ts +0 -77
  89. package/dist/lib/models/firstname.js +0 -131
  90. package/dist/lib/models/firstname.js.map +0 -1
  91. package/dist/lib/models/fullname.d.ts +0 -73
  92. package/dist/lib/models/fullname.js +0 -99
  93. package/dist/lib/models/fullname.js.map +0 -1
  94. package/dist/lib/models/index.d.ts +0 -13
  95. package/dist/lib/models/index.js +0 -16
  96. package/dist/lib/models/index.js.map +0 -1
  97. package/dist/lib/models/lastname.d.ts +0 -80
  98. package/dist/lib/models/lastname.js +0 -157
  99. package/dist/lib/models/lastname.js.map +0 -1
  100. package/dist/lib/models/misc.d.ts +0 -108
  101. package/dist/lib/models/misc.js +0 -3
  102. package/dist/lib/models/misc.js.map +0 -1
  103. package/dist/lib/models/name.d.ts +0 -76
  104. package/dist/lib/models/name.js +0 -115
  105. package/dist/lib/models/name.js.map +0 -1
  106. package/dist/lib/models/summary.d.ts +0 -26
  107. package/dist/lib/models/summary.js +0 -61
  108. package/dist/lib/models/summary.js.map +0 -1
  109. package/dist/lib/validators/array-name.validator.d.ts +0 -25
  110. package/dist/lib/validators/array-name.validator.js +0 -75
  111. package/dist/lib/validators/array-name.validator.js.map +0 -1
  112. package/dist/lib/validators/array-string.validator.d.ts +0 -43
  113. package/dist/lib/validators/array-string.validator.js +0 -76
  114. package/dist/lib/validators/array-string.validator.js.map +0 -1
  115. package/dist/lib/validators/common/validation-error.d.ts +0 -19
  116. package/dist/lib/validators/common/validation-error.js +0 -26
  117. package/dist/lib/validators/common/validation-error.js.map +0 -1
  118. package/dist/lib/validators/common/validation-rule.d.ts +0 -72
  119. package/dist/lib/validators/common/validation-rule.js +0 -76
  120. package/dist/lib/validators/common/validation-rule.js.map +0 -1
  121. package/dist/lib/validators/common/validation-type.d.ts +0 -24
  122. package/dist/lib/validators/common/validation-type.js +0 -28
  123. package/dist/lib/validators/common/validation-type.js.map +0 -1
  124. package/dist/lib/validators/firstname.validator.d.ts +0 -20
  125. package/dist/lib/validators/firstname.validator.js +0 -29
  126. package/dist/lib/validators/firstname.validator.js.map +0 -1
  127. package/dist/lib/validators/fullname.validator.d.ts +0 -21
  128. package/dist/lib/validators/fullname.validator.js +0 -38
  129. package/dist/lib/validators/fullname.validator.js.map +0 -1
  130. package/dist/lib/validators/index.d.ts +0 -21
  131. package/dist/lib/validators/index.js +0 -35
  132. package/dist/lib/validators/index.js.map +0 -1
  133. package/dist/lib/validators/lastname.validator.d.ts +0 -20
  134. package/dist/lib/validators/lastname.validator.js +0 -29
  135. package/dist/lib/validators/lastname.validator.js.map +0 -1
  136. package/dist/lib/validators/middlename.validator.d.ts +0 -20
  137. package/dist/lib/validators/middlename.validator.js +0 -38
  138. package/dist/lib/validators/middlename.validator.js.map +0 -1
  139. package/dist/lib/validators/nama.validator.d.ts +0 -21
  140. package/dist/lib/validators/nama.validator.js +0 -44
  141. package/dist/lib/validators/nama.validator.js.map +0 -1
  142. package/dist/lib/validators/namon.validator.d.ts +0 -20
  143. package/dist/lib/validators/namon.validator.js +0 -29
  144. package/dist/lib/validators/namon.validator.js.map +0 -1
  145. package/dist/lib/validators/prefix.validator.d.ts +0 -14
  146. package/dist/lib/validators/prefix.validator.js +0 -31
  147. package/dist/lib/validators/prefix.validator.js.map +0 -1
  148. package/dist/lib/validators/string-name.validator.d.ts +0 -20
  149. package/dist/lib/validators/string-name.validator.js +0 -29
  150. package/dist/lib/validators/string-name.validator.js.map +0 -1
  151. package/dist/lib/validators/suffix.validator.d.ts +0 -14
  152. package/dist/lib/validators/suffix.validator.js +0 -31
  153. package/dist/lib/validators/suffix.validator.js.map +0 -1
  154. package/dist/lib/validators/validator.d.ts +0 -13
  155. package/dist/lib/validators/validator.js +0 -9
  156. package/dist/lib/validators/validator.js.map +0 -1
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Last name class definition
5
- *
6
- * Created on March 06, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- const core_1 = require("../core");
11
- /**
12
- * Represents a last name with some extra functionalities
13
- * @class
14
- * @extends Name
15
- */
16
- class Lastname extends index_1.Name {
17
- /**
18
- * Constructs a `Lastname`
19
- * @param {string} father a piece of string that will be defined as a namon
20
- * @param {string} [mother] additional pieces considered as a last name
21
- * @param {LastnameFormat} [format] how to output a surname considering its
22
- * subparts
23
- */
24
- constructor(father, mother, format = 'father') {
25
- super(father, index_1.Namon.LAST_NAME);
26
- this.father = father;
27
- this.mother = mother;
28
- this.format = format;
29
- }
30
- /**
31
- * Determines whether a 'mother' subpart was set
32
- */
33
- hasMother() {
34
- return !!this.mother && this.mother.length > 0;
35
- }
36
- /**
37
- * Gives some descriptive statistics that summarize the central tendency,
38
- * dispersion and shape of the characters' distribution.
39
- * @param {LastnameFormat} [format] overrides the how-to format of a surname
40
- * output, considering its subparts.
41
- * @see {@link describe} in `Namefully` class for further information
42
- */
43
- describe(format) {
44
- format = format || this.format;
45
- return new index_1.Summary(this.tostring(format));
46
- }
47
- /**
48
- * Returns a string representation of the last name
49
- * @param {LastnameFormat} [format] overrides the how-to format of a surname
50
- * output, considering its subparts.
51
- */
52
- tostring(format) {
53
- format = format || this.format;
54
- switch (format) {
55
- case 'father':
56
- return this.father;
57
- case 'mother':
58
- return this.mother || index_1.Separator.EMPTY;
59
- case 'hyphenated':
60
- return this.mother ? this.father.concat(index_1.Separator.HYPHEN, this.mother) : this.father;
61
- case 'all':
62
- return this.mother ? this.father.concat(index_1.Separator.SPACE, this.mother) : this.father;
63
- }
64
- }
65
- /**
66
- * Gets the initials of the last name
67
- */
68
- getInitials(format) {
69
- format = format || this.format;
70
- const initials = [];
71
- switch (format) {
72
- case 'father':
73
- initials.push(this.father[0]);
74
- break;
75
- case 'mother':
76
- if (this.hasMother())
77
- initials.push(this.mother[0]);
78
- break;
79
- case 'hyphenated':
80
- case 'all':
81
- initials.push(this.father[0]);
82
- if (this.hasMother())
83
- initials.push(this.mother[0]);
84
- break;
85
- }
86
- return initials;
87
- }
88
- /**
89
- * Capitalizes a last name
90
- * @param {'initial' | 'all'} option how to capitalize its subparts
91
- */
92
- capitalize(option = 'initial') {
93
- super.capitalize(option);
94
- if (option === 'initial') {
95
- this.father = this.father[0].toUpperCase().concat(this.father.slice(1));
96
- if (this.hasMother())
97
- this.mother = this.mother[0].toUpperCase().concat(this.mother.slice(1));
98
- }
99
- else {
100
- this.father = this.father.toUpperCase();
101
- if (this.hasMother())
102
- this.mother = this.mother.toUpperCase();
103
- }
104
- return this;
105
- }
106
- /**
107
- * De-capitalizes a last name
108
- * @param {'initial' | 'all'} option how to decapitalize its subparts
109
- */
110
- decapitalize(option = 'initial') {
111
- super.capitalize(option);
112
- if (option === 'initial') {
113
- this.father = this.father[0].toLowerCase().concat(this.father.slice(1));
114
- if (this.hasMother())
115
- this.mother = this.mother[0].toLowerCase().concat(this.mother.slice(1));
116
- }
117
- else {
118
- this.father = this.father.toLowerCase();
119
- if (this.hasMother())
120
- this.mother = this.mother.toLowerCase();
121
- }
122
- return this;
123
- }
124
- /**
125
- * Normalizes the last name as it should be
126
- */
127
- normalize() {
128
- this.father = this.father[0]
129
- .toUpperCase()
130
- .concat(this.father.slice(1).toLowerCase());
131
- if (this.hasMother())
132
- this.mother = this.mother[0]
133
- .toUpperCase()
134
- .concat(this.mother.slice(1).toLowerCase());
135
- return this;
136
- }
137
- /**
138
- * Returns an ascii representation of each characters of a last name
139
- * @param restrictions chars to skip
140
- */
141
- ascii(restrictions) {
142
- return core_1.convertToAscii(this.tostring(), restrictions);
143
- }
144
- /**
145
- * Returns a password-like representation of a last name
146
- */
147
- passwd() {
148
- return core_1.generatePassword(this.tostring());
149
- }
150
- }
151
- exports.Lastname = Lastname;
152
- Lastname.prototype.cap = Lastname.prototype.capitalize;
153
- Lastname.prototype.decap = Lastname.prototype.decapitalize;
154
- Lastname.prototype.norm = Lastname.prototype.normalize;
155
- Lastname.prototype.stats = Lastname.prototype.describe;
156
- Lastname.prototype.inits = Lastname.prototype.getInitials;
157
- //# sourceMappingURL=lastname.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lastname.js","sourceRoot":"","sources":["../../../src/models/lastname.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAA0E;AAC1E,kCAA2D;AAE3D;;;;GAIG;AACH,MAAa,QAAS,SAAQ,YAAI;IAE9B;;;;;;OAMG;IACH,YAAmB,MAAc,EAAS,MAAe,EAAU,SAAyB,QAAQ;QAChG,KAAK,CAAC,MAAM,EAAE,aAAK,CAAC,SAAS,CAAC,CAAC;QADhB,WAAM,GAAN,MAAM,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAS;QAAU,WAAM,GAAN,MAAM,CAA2B;IAEpG,CAAC;IAED;;OAEG;IACH,SAAS;QACL,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,MAAuB;QAC5B,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC/B,OAAO,IAAI,eAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAuB;QAC5B,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC/B,QAAO,MAAM,EAAE;YACX,KAAK,QAAQ;gBACT,OAAO,IAAI,CAAC,MAAM,CAAC;YACvB,KAAK,QAAQ;gBACT,OAAO,IAA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AAS,CAAC,WAAW,CAAC"}
@@ -1,108 +0,0 @@
1
- /**
2
- * Miscellaneous types
3
- *
4
- * Created on March 07, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Parser } from '../core/parsers';
8
- import { Separator } from './enums';
9
- /**
10
- * Defines the two ways that a full name can be ordered: first or last name
11
- * @typedef NameOrder
12
- */
13
- export declare type NameOrder = 'firstname' | 'fn' | 'lastname' | 'ln';
14
- /**
15
- * Defines the three parts that a birth name
16
- * @typedef NameType
17
- */
18
- export declare type NameType = 'firstname' | 'fn' | 'lastname' | 'ln' | 'middlename' | 'mn';
19
- /**
20
- * Defines the distinct formats to output a surname
21
- * @typedef LastnameFormat
22
- */
23
- export declare type LastnameFormat = 'father' | 'mother' | 'hyphenated' | 'all';
24
- /**
25
- * Defines the ways the international community defines a title
26
- *
27
- * American and Canadian English follow slightly different rules for abbreviated
28
- * titles than British and Australian English. In North American English, titles
29
- * before a name require a period: `Mr., Mrs., Ms., Dr.` In British and Australian
30
- * English, no full stops are used in these abbreviations.
31
- * @typedef AbbrTitle
32
- */
33
- export declare type AbbrTitle = 'us' | 'uk';
34
- /**
35
- * Interface for JSON signature that represents the configuration of the utility
36
- * @interface
37
- */
38
- export interface Config {
39
- /**
40
- * The order of appearance of a full name: by first name or last name
41
- */
42
- orderedBy: NameOrder;
43
- /**
44
- * For literal string input, this is the parameter used to indicate the token
45
- * to utilize to split the string names.
46
- */
47
- separator: Separator;
48
- /**
49
- * Whether or not to add period to a prefix using the American or British way.
50
- */
51
- titling: AbbrTitle;
52
- /**
53
- * Indicates if the ending suffix should be separated with a comma or space.
54
- */
55
- ending: boolean;
56
- /**
57
- * Bypass the validation rules with this option. Since we only provide a
58
- * handful of suffixes or prefixes in English, this paramter is ideal to
59
- * avoid checking the validity of them.
60
- */
61
- bypass: boolean;
62
- /**
63
- * Custom parser, a user-defined parser indicating how to the name set is
64
- * organized. Namefully cannot guess it.
65
- */
66
- parser?: Parser<any>;
67
- /**
68
- * how to format a surname:
69
- * - 'father' (father name only)
70
- * - 'mother' (mother name only)
71
- * - 'hyphenated' (joining both father and mother names with a hyphen)
72
- * - 'all' (joining both father and mother names with a space).
73
- *
74
- * This parameter can be set either by an instance of a last name or during
75
- * the creation of a namefully instance. To avoid ambiguity, we prioritize as
76
- * source of truth the value set as optional parameter when instantiating
77
- * namefully.
78
- */
79
- lastnameFormat?: LastnameFormat;
80
- }
81
- /**
82
- * @interface Nama represents the JSON signature for the `NamaParser`
83
- */
84
- export interface Nama {
85
- prefix?: string;
86
- firstname: string;
87
- middlename?: string;
88
- lastname: string;
89
- suffix?: string;
90
- }
91
- /**
92
- * @interface Indexing represents the JSON signature for indexing name parts
93
- */
94
- interface Indexing<T> {
95
- prefix: T;
96
- firstname: T;
97
- middlename: T;
98
- lastname: T;
99
- suffix: T;
100
- }
101
- /**
102
- * @interface NameIndex represents the JSON signature for indexing name parts
103
- * using numbered index
104
- * @extends Index<number>
105
- */
106
- export interface NameIndex extends Indexing<number> {
107
- }
108
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=misc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../src/models/misc.ts"],"names":[],"mappings":""}
@@ -1,76 +0,0 @@
1
- /**
2
- * Name class definition
3
- *
4
- * Created on March 06, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Summary, Namon } from './index';
8
- /**
9
- * Represents a namon with some extra functionalities
10
- * @class
11
- * @see {@link Namon} interface to understand the concept of namon/nama.
12
- */
13
- export declare class Name {
14
- namon: string;
15
- type: Namon;
16
- private readonly initial;
17
- private readonly body;
18
- /**
19
- * Constructs a `Name`
20
- * @param namon a piece of string that will be defined as a namon
21
- * @param type which namon that is
22
- * @param cap which kind of capitalizations
23
- */
24
- constructor(namon: string, type: Namon, cap?: 'initial' | 'all');
25
- /**
26
- * Gives some descriptive statistics that summarize the central tendency,
27
- * dispersion and shape of the characters' distribution.
28
- * @see {@link describe} in `Namefully` class for further information
29
- */
30
- describe(): Summary;
31
- /**
32
- * Returns a string representation of the namon
33
- */
34
- tostring(): string;
35
- /**
36
- * Gets the initials of the name
37
- */
38
- getInitials(): string[];
39
- /**
40
- * Capitalizes a name
41
- * @param {'initial' | 'all'} option how to capitalize it
42
- */
43
- capitalize(option?: 'initial' | 'all'): Name;
44
- /**
45
- * De-capitalizes a name
46
- * @param {'initial' | 'all'} option how to decapitalize it
47
- */
48
- decapitalize(option?: 'initial' | 'all'): Name;
49
- /**
50
- * Normalizes the name as it should be
51
- */
52
- normalize(): Name;
53
- /**
54
- * Resets to the initial namon
55
- */
56
- reset(): Name;
57
- /**
58
- * Returns an ascii representation of each characters of a name
59
- * @param restrictions chars to skip
60
- */
61
- ascii(restrictions?: string[]): number[];
62
- /**
63
- * Returns a password-like representation of a name
64
- */
65
- passwd(): string;
66
- }
67
- /**
68
- * Aliases for `Name`
69
- */
70
- export interface Name {
71
- cap: typeof Name.prototype.capitalize;
72
- decap: typeof Name.prototype.decapitalize;
73
- norm: typeof Name.prototype.normalize;
74
- stats: typeof Name.prototype.describe;
75
- inits: typeof Name.prototype.getInitials;
76
- }
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Name class definition
5
- *
6
- * Created on March 06, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- const core_1 = require("../core");
11
- /**
12
- * Represents a namon with some extra functionalities
13
- * @class
14
- * @see {@link Namon} interface to understand the concept of namon/nama.
15
- */
16
- class Name {
17
- /**
18
- * Constructs a `Name`
19
- * @param namon a piece of string that will be defined as a namon
20
- * @param type which namon that is
21
- * @param cap which kind of capitalizations
22
- */
23
- constructor(namon, type, cap) {
24
- this.namon = namon;
25
- this.type = type;
26
- this.initial = namon[0];
27
- this.body = namon.slice(1);
28
- if (!!cap)
29
- this.capitalize(cap);
30
- }
31
- /**
32
- * Gives some descriptive statistics that summarize the central tendency,
33
- * dispersion and shape of the characters' distribution.
34
- * @see {@link describe} in `Namefully` class for further information
35
- */
36
- describe() {
37
- return new index_1.Summary(this.namon);
38
- }
39
- /**
40
- * Returns a string representation of the namon
41
- */
42
- tostring() {
43
- return this.namon;
44
- }
45
- /**
46
- * Gets the initials of the name
47
- */
48
- getInitials() {
49
- return [this.namon[0]];
50
- }
51
- /**
52
- * Capitalizes a name
53
- * @param {'initial' | 'all'} option how to capitalize it
54
- */
55
- capitalize(option = 'initial') {
56
- const initial = this.initial.toUpperCase();
57
- if (option === 'initial') {
58
- this.namon = initial.concat(this.body);
59
- }
60
- else {
61
- this.namon = this.namon.toUpperCase();
62
- }
63
- return this;
64
- }
65
- /**
66
- * De-capitalizes a name
67
- * @param {'initial' | 'all'} option how to decapitalize it
68
- */
69
- decapitalize(option = 'initial') {
70
- const initial = this.initial.toLowerCase();
71
- if (option === 'initial') {
72
- this.namon = initial.concat(this.body);
73
- }
74
- else {
75
- this.namon = initial.concat(this.body.toLowerCase());
76
- }
77
- return this;
78
- }
79
- /**
80
- * Normalizes the name as it should be
81
- */
82
- normalize() {
83
- this.namon = this.namon[0]
84
- .toUpperCase()
85
- .concat(this.namon.slice(1).toLowerCase());
86
- return this;
87
- }
88
- /**
89
- * Resets to the initial namon
90
- */
91
- reset() {
92
- this.namon = this.initial.concat(this.body);
93
- return this;
94
- }
95
- /**
96
- * Returns an ascii representation of each characters of a name
97
- * @param restrictions chars to skip
98
- */
99
- ascii(restrictions) {
100
- return core_1.convertToAscii(this.namon, restrictions);
101
- }
102
- /**
103
- * Returns a password-like representation of a name
104
- */
105
- passwd() {
106
- return core_1.generatePassword(this.namon);
107
- }
108
- }
109
- exports.Name = Name;
110
- Name.prototype.cap = Name.prototype.capitalize;
111
- Name.prototype.decap = Name.prototype.decapitalize;
112
- Name.prototype.norm = Name.prototype.normalize;
113
- Name.prototype.stats = Name.prototype.describe;
114
- Name.prototype.inits = Name.prototype.getInitials;
115
- //# sourceMappingURL=name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"name.js","sourceRoot":"","sources":["../../../src/models/name.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAyC;AACzC,kCAA2D;AAE3D;;;;GAIG;AACH,MAAa,IAAI;IAKb;;;;;OAKG;IACH,YAAmB,KAAa,EAAS,IAAW,EAAE,GAAuB;QAA1D,UAAK,GAAL,KAAK,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAO;QAChD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG;YAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACJ,OAAO,IAAI,eAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,WAAW;QACP,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,SAA4B,SAAS;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3C,IAAI,MAAM,KAAK,SAAS,EAAE;YACtB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1C;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;SACzC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,S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SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;AAC/C,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Represents the statistical summary of a string representation
3
- * @class
4
- */
5
- export declare class Summary {
6
- private namon;
7
- distribution: {
8
- [key: string]: number;
9
- };
10
- count: number;
11
- frequency: number;
12
- top: string;
13
- unique: number;
14
- /**
15
- * Creates a `Summary` of a given string of alphabetical characters
16
- * @param namon piece of name
17
- * @param restrictions a set of undesired characters
18
- */
19
- constructor(namon: string, restrictions?: string[]);
20
- /**
21
- * Returns a string representation of the summary
22
- */
23
- tostring(): string;
24
- private compute;
25
- private groupByChar;
26
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Summary of descriptive stats of the name
5
- *
6
- * Created on March 06, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- /**
11
- * Represents the statistical summary of a string representation
12
- * @class
13
- */
14
- class Summary {
15
- /**
16
- * Creates a `Summary` of a given string of alphabetical characters
17
- * @param namon piece of name
18
- * @param restrictions a set of undesired characters
19
- */
20
- constructor(namon, restrictions = [index_1.Separator.SPACE]) {
21
- this.namon = namon;
22
- this.compute(restrictions);
23
- }
24
- /**
25
- * Returns a string representation of the summary
26
- */
27
- tostring() {
28
- return index_1.Separator.EMPTY.concat(`Descriptive statistics for "${this.namon}" \n`, `count : ${this.count} \n`, `frequency: ${this.frequency} \n`, `top : ${this.top} \n`, `unique : ${this.unique} \n`, `distrib : ${Object.entries(this.distribution).map(e => `${e[1]}${e[0]}`).join(',')} \n`);
29
- }
30
- compute(restrictions = []) {
31
- // compute stats for the string
32
- let count = 0, maxfreq = 0, uniq = 0, top = '';
33
- const freqs = this.groupByChar();
34
- for (const char in freqs) {
35
- if (restrictions.indexOf(char) === -1) {
36
- count += freqs[char];
37
- if (freqs[char] >= maxfreq) {
38
- maxfreq = freqs[char];
39
- top = char;
40
- }
41
- uniq++;
42
- }
43
- }
44
- this.distribution = freqs;
45
- this.count = count;
46
- this.frequency = maxfreq;
47
- this.top = top;
48
- this.unique = uniq;
49
- }
50
- groupByChar() {
51
- const frequencies = {};
52
- for (const char of this.namon.toUpperCase())
53
- if (Object.keys(frequencies).includes(char))
54
- frequencies[char] += 1;
55
- else
56
- frequencies[char] = 1;
57
- return frequencies;
58
- }
59
- }
60
- exports.Summary = Summary;
61
- //# sourceMappingURL=summary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/models/summary.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAoC;AAEpC;;;GAGG;AACH,MAAa,OAAO;IAOhB;;;;OAIG;IACH,YAAoB,KAAa,EAAE,eAAyB,CAAC,iBAAS,CAAC,KAAK,CAAC;QAAzD,UAAK,GAAL,KAAK,CAAQ;QAC7B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,iBAAS,CAAC,KAAK,CAAC,MAAM,CACzB,+BAA+B,IAAI,CAAC,KAAK,MAAM,EAC/C,cAAc,IAAI,CAAC,KAAK,KAAK,EAC7B,cAAc,IAAI,CAAC,SAAS,KAAK,EACjC,cAAc,IAAI,CAAC,GAAG,KAAK,EAC3B,cAAc,IAAI,CAAC,MAAM,KAAK,EAC9B,cAAc,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAC5F,CAAC;IACN,CAAC;IAEO,OAAO,CAAC,eAAyB,EAAE;QACvC,+BAA+B;QAC/B,IAAI,KAAK,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;gBACnC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;gBACrB,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE;oBACxB,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;oBACtB,GAAG,GAAG,IAAI,CAAC;iBACd;gBACD,IAAI,EAAE,CAAC;aACV;SACJ;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAEO,WAAW;QACf,MAAM,WAAW,GAA8B,EAAE,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACvC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACvC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBAEvB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AA9DD,0BA8DC"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Array of `Name` validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Name } from '../models';
8
- import { Validator, ValidatorType } from './index';
9
- /**
10
- * Represents a validator to help the array `Name` parser
11
- * @class
12
- * @classdesc
13
- * This validator validates a array of `Name` objects following a specific order
14
- * based on the count of elements. It is expected that the array has to be
15
- * between two and five elements.
16
- *
17
- */
18
- export default class ArrayNameValidator implements Validator<Name[]> {
19
- readonly type: ValidatorType;
20
- /**
21
- * Validates the content of a set of custom `Name`s
22
- * @param {Name[]} value data to validate
23
- */
24
- validate(values: Name[]): void;
25
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Array of `Name` validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const models_1 = require("../models");
10
- const index_1 = require("./index");
11
- const constants_1 = require("../core/constants");
12
- /**
13
- * Represents a validator to help the array `Name` parser
14
- * @class
15
- * @classdesc
16
- * This validator validates a array of `Name` objects following a specific order
17
- * based on the count of elements. It is expected that the array has to be
18
- * between two and five elements.
19
- *
20
- */
21
- class ArrayNameValidator {
22
- constructor() {
23
- this.type = index_1.ValidatorType.ARR_NAMES;
24
- }
25
- /**
26
- * Validates the content of a set of custom `Name`s
27
- * @param {Name[]} value data to validate
28
- */
29
- validate(values) {
30
- if (values.length < constants_1.MIN_NUMBER_NAME_PART || values.length > constants_1.MAX_NUMBER_NAME_PART)
31
- throw new index_1.ValidationError(`must be an array of ${constants_1.MIN_NUMBER_NAME_PART} - ` +
32
- `${constants_1.MAX_NUMBER_NAME_PART} 'Name's`, 'Array of Names');
33
- const validators = {
34
- [models_1.Namon.PREFIX]: new index_1.PrefixValidator(),
35
- [models_1.Namon.FIRST_NAME]: new index_1.FirstnameValidator(),
36
- [models_1.Namon.MIDDLE_NAME]: new index_1.MiddlenameValidator(),
37
- [models_1.Namon.LAST_NAME]: new index_1.LastnameValidator(),
38
- [models_1.Namon.SUFFIX]: new index_1.SuffixValidator(),
39
- };
40
- switch (values.length) {
41
- case constants_1.FIRST_LAST_NAME_INDEX:
42
- values.forEach(n => {
43
- if (![models_1.Namon.FIRST_NAME, models_1.Namon.LAST_NAME].includes(n.type))
44
- throw new index_1.ValidationError('Both first and last names are required');
45
- validators[n.type].validate(n.tostring());
46
- });
47
- break;
48
- case constants_1.FIRST_MIDDLE_LAST_NAME_INDEX:
49
- values.forEach(n => {
50
- if (![models_1.Namon.FIRST_NAME, models_1.Namon.MIDDLE_NAME, models_1.Namon.LAST_NAME].includes(n.type))
51
- throw new index_1.ValidationError('First, middle and last names are required');
52
- validators[n.type].validate(n.tostring());
53
- });
54
- break;
55
- case constants_1.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX:
56
- values.forEach(n => {
57
- if (![models_1.Namon.PREFIX, models_1.Namon.FIRST_NAME, models_1.Namon.MIDDLE_NAME,
58
- models_1.Namon.LAST_NAME].includes(n.type))
59
- throw new index_1.ValidationError('More fields are required');
60
- validators[n.type].validate(n.tostring());
61
- });
62
- break;
63
- case constants_1.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX:
64
- values.forEach(n => {
65
- if (![models_1.Namon.PREFIX, models_1.Namon.FIRST_NAME, models_1.Namon.MIDDLE_NAME, models_1.Namon.LAST_NAME,
66
- models_1.Namon.SUFFIX].includes(n.type))
67
- throw new index_1.ValidationError('More fields are required');
68
- validators[n.type].validate(n.tostring());
69
- });
70
- break;
71
- }
72
- }
73
- }
74
- exports.default = ArrayNameValidator;
75
- //# sourceMappingURL=array-name.validator.js.map