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
@@ -0,0 +1,177 @@
1
+ import { CapsRange, Namon, Surname } from './types';
2
+ /**
3
+ * Representation of a string type name with some extra capabilities.
4
+ */
5
+ export declare class Name {
6
+ readonly type: Namon;
7
+ private namon;
8
+ protected initial: string;
9
+ protected capsRange: CapsRange;
10
+ /**
11
+ * Creates augmented names by adding extra functionality to a string name.
12
+ * @param type must be indicated to categorize the name so it can be
13
+ * treated accordingly.
14
+ * @param capsRange determines how the name should be capitalized initially.
15
+ */
16
+ constructor(value: string, type: Namon, capsRange?: CapsRange);
17
+ set value(newValue: string);
18
+ /**
19
+ * The piece of string treated as a name.
20
+ */
21
+ get value(): string;
22
+ /**
23
+ * The length of the name.
24
+ */
25
+ get length(): number;
26
+ /**
27
+ * Whether the name is a prefix.
28
+ */
29
+ get isPrefix(): boolean;
30
+ /**
31
+ * Whether the name is a first name.
32
+ */
33
+ get isFirstName(): boolean;
34
+ /**
35
+ * Whether the name is a middle name.
36
+ */
37
+ get isMiddleName(): boolean;
38
+ /**
39
+ * Whether the name is a last name.
40
+ */
41
+ get isLastName(): boolean;
42
+ /**
43
+ * Whether the name is a suffix.
44
+ */
45
+ get isSuffix(): boolean;
46
+ /**
47
+ * Creates a prefix.
48
+ */
49
+ static prefix(value: string): Name;
50
+ /**
51
+ * Creates a first name.
52
+ */
53
+ static first(value: string): Name;
54
+ /**
55
+ * Creates a middle name.
56
+ */
57
+ static middle(value: string): Name;
58
+ /**
59
+ * Creates a last name.
60
+ */
61
+ static last(value: string): Name;
62
+ /**
63
+ * Creates a suffix.
64
+ */
65
+ static suffix(value: string): Name;
66
+ /**
67
+ * Gets the initials (first character) of this name.
68
+ */
69
+ initials(): string[];
70
+ /**
71
+ * String representation of this object.
72
+ */
73
+ toString(): string;
74
+ /**
75
+ * Returns true if the other is equal to this name.
76
+ */
77
+ equal(other: Name | unknown): boolean;
78
+ /**
79
+ * Capitalizes the name.
80
+ */
81
+ caps(range?: CapsRange): Name;
82
+ /**
83
+ * De-capitalizes the name.
84
+ */
85
+ decaps(range?: CapsRange): Name;
86
+ }
87
+ /**
88
+ * Representation of a first name with some extra functionality.
89
+ */
90
+ export declare class FirstName extends Name {
91
+ private _more;
92
+ /**
93
+ * Creates an extended version of `Name` and flags it as a first name `type`.
94
+ *
95
+ * Some may consider `more` additional name parts of a given name as their
96
+ * first names, but not as their middle names. Though, it may mean the same,
97
+ * `more` provides the freedom to do it as it pleases.
98
+ */
99
+ constructor(value: string, ...more: string[]);
100
+ /**
101
+ * Determines whether a first name has `more` name parts.
102
+ */
103
+ get hasMore(): boolean;
104
+ get length(): number;
105
+ /**
106
+ * Returns a combined version of the `value` and `more` if any.
107
+ */
108
+ get asNames(): Name[];
109
+ /**
110
+ * The additional name parts of the first name.
111
+ */
112
+ get more(): string[];
113
+ toString(withMore?: boolean): string;
114
+ initials(withMore?: boolean): string[];
115
+ caps(range?: CapsRange): FirstName;
116
+ decaps(range?: CapsRange): FirstName;
117
+ /**
118
+ * Makes a copy of the current name.
119
+ */
120
+ copyWith(values?: {
121
+ first?: string;
122
+ more?: string[];
123
+ }): FirstName;
124
+ }
125
+ /**
126
+ * Representation of a last name with some extra functionality.
127
+ */
128
+ export declare class LastName extends Name {
129
+ readonly format: Surname;
130
+ private _mother?;
131
+ /**
132
+ * Creates an extended version of `Name` and flags it as a last name `type`.
133
+ *
134
+ * Some people may keep their `mother`'s surname and want to keep a clear cut
135
+ * from their `father`'s surname. However, there are no clear rules about it.
136
+ */
137
+ constructor(father: string, mother?: string, format?: Surname);
138
+ /**
139
+ * The surname inherited from a father side.
140
+ */
141
+ get father(): string;
142
+ /**
143
+ * The surname inherited from a mother side.
144
+ */
145
+ get mother(): string | undefined;
146
+ /**
147
+ * Returns `true` if the mother's surname is defined.
148
+ */
149
+ get hasMother(): boolean;
150
+ get length(): number;
151
+ /**
152
+ * Returns a combined version of the `father` and `mother` if any.
153
+ */
154
+ get asNames(): Name[];
155
+ toString(format?: Surname): string;
156
+ initials(format?: Surname): string[];
157
+ caps(range?: CapsRange): LastName;
158
+ decaps(range?: CapsRange): LastName;
159
+ /**
160
+ * Makes a copy of the current name.
161
+ */
162
+ copyWith(values?: {
163
+ father?: string;
164
+ mother?: string;
165
+ format?: Surname;
166
+ }): LastName;
167
+ }
168
+ /**
169
+ * JSON signature for `FullName` data.
170
+ */
171
+ export interface JsonName {
172
+ prefix?: string;
173
+ firstName: string;
174
+ middleName?: string[];
175
+ lastName: string;
176
+ suffix?: string;
177
+ }
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LastName = exports.FirstName = exports.Name = void 0;
4
+ const error_1 = require("./error");
5
+ const types_1 = require("./types");
6
+ const utils_1 = require("./utils");
7
+ /**
8
+ * Representation of a string type name with some extra capabilities.
9
+ */
10
+ class Name {
11
+ /**
12
+ * Creates augmented names by adding extra functionality to a string name.
13
+ * @param type must be indicated to categorize the name so it can be
14
+ * treated accordingly.
15
+ * @param capsRange determines how the name should be capitalized initially.
16
+ */
17
+ constructor(value, type, capsRange) {
18
+ this.type = type;
19
+ this.capsRange = capsRange !== null && capsRange !== void 0 ? capsRange : types_1.CapsRange.INITIAL;
20
+ this.value = value;
21
+ if (capsRange)
22
+ this.caps(capsRange);
23
+ }
24
+ set value(newValue) {
25
+ if (newValue.trim().length < 2) {
26
+ throw new error_1.InputError({ source: newValue, message: 'must be 2+ characters' });
27
+ }
28
+ this.namon = newValue;
29
+ this.initial = newValue[0];
30
+ }
31
+ /**
32
+ * The piece of string treated as a name.
33
+ */
34
+ get value() {
35
+ return this.namon;
36
+ }
37
+ /**
38
+ * The length of the name.
39
+ */
40
+ get length() {
41
+ return this.namon.length;
42
+ }
43
+ /**
44
+ * Whether the name is a prefix.
45
+ */
46
+ get isPrefix() {
47
+ return this.type === types_1.Namon.PREFIX;
48
+ }
49
+ /**
50
+ * Whether the name is a first name.
51
+ */
52
+ get isFirstName() {
53
+ return this.type === types_1.Namon.FIRST_NAME;
54
+ }
55
+ /**
56
+ * Whether the name is a middle name.
57
+ */
58
+ get isMiddleName() {
59
+ return this.type === types_1.Namon.MIDDLE_NAME;
60
+ }
61
+ /**
62
+ * Whether the name is a last name.
63
+ */
64
+ get isLastName() {
65
+ return this.type === types_1.Namon.LAST_NAME;
66
+ }
67
+ /**
68
+ * Whether the name is a suffix.
69
+ */
70
+ get isSuffix() {
71
+ return this.type === types_1.Namon.SUFFIX;
72
+ }
73
+ /**
74
+ * Creates a prefix.
75
+ */
76
+ static prefix(value) {
77
+ return new this(value, types_1.Namon.PREFIX);
78
+ }
79
+ /**
80
+ * Creates a first name.
81
+ */
82
+ static first(value) {
83
+ return new this(value, types_1.Namon.FIRST_NAME);
84
+ }
85
+ /**
86
+ * Creates a middle name.
87
+ */
88
+ static middle(value) {
89
+ return new this(value, types_1.Namon.MIDDLE_NAME);
90
+ }
91
+ /**
92
+ * Creates a last name.
93
+ */
94
+ static last(value) {
95
+ return new this(value, types_1.Namon.LAST_NAME);
96
+ }
97
+ /**
98
+ * Creates a suffix.
99
+ */
100
+ static suffix(value) {
101
+ return new this(value, types_1.Namon.SUFFIX);
102
+ }
103
+ /**
104
+ * Gets the initials (first character) of this name.
105
+ */
106
+ initials() {
107
+ return [this.initial];
108
+ }
109
+ /**
110
+ * String representation of this object.
111
+ */
112
+ toString() {
113
+ return this.namon;
114
+ }
115
+ /**
116
+ * Returns true if the other is equal to this name.
117
+ */
118
+ equal(other) {
119
+ return other instanceof Name && other.value === this.value && other.type === this.type;
120
+ }
121
+ /**
122
+ * Capitalizes the name.
123
+ */
124
+ caps(range) {
125
+ this.value = utils_1.capitalize(this.namon, range !== null && range !== void 0 ? range : this.capsRange);
126
+ return this;
127
+ }
128
+ /**
129
+ * De-capitalizes the name.
130
+ */
131
+ decaps(range) {
132
+ this.value = utils_1.decapitalize(this.namon, range !== null && range !== void 0 ? range : this.capsRange);
133
+ return this;
134
+ }
135
+ }
136
+ exports.Name = Name;
137
+ /**
138
+ * Representation of a first name with some extra functionality.
139
+ */
140
+ class FirstName extends Name {
141
+ /**
142
+ * Creates an extended version of `Name` and flags it as a first name `type`.
143
+ *
144
+ * Some may consider `more` additional name parts of a given name as their
145
+ * first names, but not as their middle names. Though, it may mean the same,
146
+ * `more` provides the freedom to do it as it pleases.
147
+ */
148
+ constructor(value, ...more) {
149
+ super(value, types_1.Namon.FIRST_NAME);
150
+ for (const name of more) {
151
+ if (name.trim().length < 2) {
152
+ throw new error_1.InputError({ source: name, message: 'must be 2+ characters' });
153
+ }
154
+ }
155
+ this._more = more;
156
+ }
157
+ /**
158
+ * Determines whether a first name has `more` name parts.
159
+ */
160
+ get hasMore() {
161
+ return this._more.length > 0;
162
+ }
163
+ get length() {
164
+ return super.length + (this.hasMore ? this._more.reduce((acc, n) => acc + n).length : 0);
165
+ }
166
+ /**
167
+ * Returns a combined version of the `value` and `more` if any.
168
+ */
169
+ get asNames() {
170
+ const names = [Name.first(this.value)];
171
+ if (this.hasMore) {
172
+ names.push(...this._more.map((n) => Name.first(n)));
173
+ }
174
+ return names;
175
+ }
176
+ /**
177
+ * The additional name parts of the first name.
178
+ */
179
+ get more() {
180
+ return this._more;
181
+ }
182
+ toString(withMore = false) {
183
+ return withMore && this.hasMore ? `${this.value} ${this._more.join(' ')}`.trim() : this.value;
184
+ }
185
+ initials(withMore = false) {
186
+ const inits = [this.initial];
187
+ if (withMore && this.hasMore) {
188
+ inits.push(...this._more.map((n) => n[0]));
189
+ }
190
+ return inits;
191
+ }
192
+ caps(range) {
193
+ range = range || this.capsRange;
194
+ this.value = utils_1.capitalize(this.value, range);
195
+ if (this.hasMore)
196
+ this._more = this._more.map((n) => utils_1.capitalize(n, range));
197
+ return this;
198
+ }
199
+ decaps(range) {
200
+ range = range || this.capsRange;
201
+ this.value = utils_1.decapitalize(this.value, range);
202
+ if (this.hasMore)
203
+ this._more = this._more.map((n) => utils_1.decapitalize(n, range));
204
+ return this;
205
+ }
206
+ /**
207
+ * Makes a copy of the current name.
208
+ */
209
+ copyWith(values) {
210
+ var _a, _b;
211
+ return new FirstName((_a = values.first) !== null && _a !== void 0 ? _a : this.value, ...((_b = values.more) !== null && _b !== void 0 ? _b : this._more));
212
+ }
213
+ }
214
+ exports.FirstName = FirstName;
215
+ /**
216
+ * Representation of a last name with some extra functionality.
217
+ */
218
+ class LastName extends Name {
219
+ /**
220
+ * Creates an extended version of `Name` and flags it as a last name `type`.
221
+ *
222
+ * Some people may keep their `mother`'s surname and want to keep a clear cut
223
+ * from their `father`'s surname. However, there are no clear rules about it.
224
+ */
225
+ constructor(father, mother, format = types_1.Surname.FATHER) {
226
+ super(father, types_1.Namon.LAST_NAME);
227
+ this.format = format;
228
+ if (mother && mother.trim().length < 2) {
229
+ throw new error_1.InputError({ source: mother, message: 'must be 2+ characters' });
230
+ }
231
+ this._mother = mother;
232
+ }
233
+ /**
234
+ * The surname inherited from a father side.
235
+ */
236
+ get father() {
237
+ return this.value;
238
+ }
239
+ /**
240
+ * The surname inherited from a mother side.
241
+ */
242
+ get mother() {
243
+ return this._mother;
244
+ }
245
+ /**
246
+ * Returns `true` if the mother's surname is defined.
247
+ */
248
+ get hasMother() {
249
+ return !!this._mother;
250
+ }
251
+ get length() {
252
+ var _a, _b;
253
+ return super.length + ((_b = (_a = this._mother) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
254
+ }
255
+ /**
256
+ * Returns a combined version of the `father` and `mother` if any.
257
+ */
258
+ get asNames() {
259
+ const names = [Name.last(this.value)];
260
+ if (this.hasMother) {
261
+ names.push(Name.last(this._mother));
262
+ }
263
+ return names;
264
+ }
265
+ toString(format) {
266
+ var _a;
267
+ format = format !== null && format !== void 0 ? format : this.format;
268
+ switch (format) {
269
+ case types_1.Surname.FATHER:
270
+ return this.value;
271
+ case types_1.Surname.MOTHER:
272
+ return (_a = this.mother) !== null && _a !== void 0 ? _a : '';
273
+ case types_1.Surname.HYPHENATED:
274
+ return this.hasMother ? `${this.value}-${this._mother}` : this.value;
275
+ case types_1.Surname.ALL:
276
+ return this.hasMother ? `${this.value} ${this._mother}` : this.value;
277
+ }
278
+ }
279
+ initials(format) {
280
+ format = format || this.format;
281
+ const inits = [];
282
+ switch (format) {
283
+ case types_1.Surname.MOTHER:
284
+ if (this.hasMother)
285
+ inits.push(this._mother[0]);
286
+ break;
287
+ case types_1.Surname.HYPHENATED:
288
+ case types_1.Surname.ALL:
289
+ inits.push(this.initial);
290
+ if (this.hasMother)
291
+ inits.push(this._mother[0]);
292
+ break;
293
+ case types_1.Surname.FATHER:
294
+ default:
295
+ inits.push(this.initial);
296
+ }
297
+ return inits;
298
+ }
299
+ caps(range) {
300
+ range = range || this.capsRange;
301
+ this.value = utils_1.capitalize(this.value, range);
302
+ if (this.hasMother)
303
+ this._mother = utils_1.capitalize(this._mother, range);
304
+ return this;
305
+ }
306
+ decaps(range) {
307
+ range = range || this.capsRange;
308
+ this.value = utils_1.decapitalize(this.value, range);
309
+ if (this.hasMother)
310
+ this._mother = utils_1.decapitalize(this._mother, range);
311
+ return this;
312
+ }
313
+ /**
314
+ * Makes a copy of the current name.
315
+ */
316
+ copyWith(values) {
317
+ var _a, _b, _c;
318
+ return new LastName((_a = values.father) !== null && _a !== void 0 ? _a : this.value, (_b = values.mother) !== null && _b !== void 0 ? _b : this.mother, (_c = values.format) !== null && _c !== void 0 ? _c : this.format);
319
+ }
320
+ }
321
+ exports.LastName = LastName;
322
+ //# sourceMappingURL=name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/name.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,mCAAmD;AACnD,mCAAkD;AAElD;;GAEG;AACH,MAAa,IAAI;IAKb;;;;;OAKG;IACH,YAAY,KAAa,EAAW,IAAW,EAAE,SAAqB;QAAlC,SAAI,GAAJ,IAAI,CAAO;QAC3C,IAAI,CAAC,SAA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