namefully 2.0.2 → 2.1.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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NameBuilder = void 0;
4
- const namefully_js_1 = require("./namefully.js");
5
4
  const validator_js_1 = require("./validator.js");
5
+ const namefully_js_1 = require("./namefully.js");
6
6
  class Builder {
7
7
  prebuild;
8
8
  postbuild;
@@ -70,11 +70,11 @@ class NameBuilder extends Builder {
70
70
  static use({ names, prebuild, postbuild, preclear, postclear, }) {
71
71
  return new NameBuilder(names ?? [], prebuild, postbuild, preclear, postclear);
72
72
  }
73
- build(config) {
73
+ build(options) {
74
74
  this.prebuild?.();
75
75
  const names = [...this.queue];
76
76
  validator_js_1.ArrayNameValidator.create().validate(names);
77
- this.instance = new namefully_js_1.Namefully(names, config);
77
+ this.instance = new namefully_js_1.Namefully(names, options);
78
78
  this.postbuild?.(this.instance);
79
79
  return this.instance;
80
80
  }
@@ -1,30 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ALLOWED_FORMAT_TOKENS = exports.MAX_NUMBER_OF_NAME_PARTS = exports.MIN_NUMBER_OF_NAME_PARTS = exports.VERSION = void 0;
4
- exports.VERSION = '2.0.2';
4
+ exports.VERSION = '2.1.0';
5
5
  exports.MIN_NUMBER_OF_NAME_PARTS = 2;
6
6
  exports.MAX_NUMBER_OF_NAME_PARTS = 5;
7
- exports.ALLOWED_FORMAT_TOKENS = [
8
- '.',
9
- ',',
10
- ' ',
11
- '-',
12
- '_',
13
- 'b',
14
- 'B',
15
- 'f',
16
- 'F',
17
- 'l',
18
- 'L',
19
- 'm',
20
- 'M',
21
- 'n',
22
- 'N',
23
- 'o',
24
- 'O',
25
- 'p',
26
- 'P',
27
- 's',
28
- 'S',
29
- '$',
30
- ];
7
+ exports.ALLOWED_FORMAT_TOKENS = ` .,_-()[]<>'"bBfFlLmMnNoOpPsS$`;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserialize = void 0;
4
+ const builder_js_1 = require("./builder.js");
5
+ const name_js_1 = require("./name.js");
6
+ const error_js_1 = require("./error.js");
7
+ function deserialize(data) {
8
+ try {
9
+ const parsed = typeof data === 'string' ? JSON.parse(data) : data;
10
+ if (!parsed || typeof parsed !== 'object') {
11
+ throw new error_js_1.InputError({
12
+ source: String(data),
13
+ message: 'invalid serialized data; must be an object or a string',
14
+ });
15
+ }
16
+ const { names, config } = parsed;
17
+ const { firstName: fn, lastName: ln, middleName: mn, prefix: px, suffix: sx } = names;
18
+ const builder = builder_js_1.NameBuilder.of();
19
+ if (px)
20
+ builder.add(name_js_1.Name.prefix(px));
21
+ if (sx)
22
+ builder.add(name_js_1.Name.suffix(sx));
23
+ if (mn)
24
+ builder.add(...mn.map((n) => name_js_1.Name.middle(n)));
25
+ builder.add(typeof fn === 'string' ? name_js_1.Name.first(fn) : new name_js_1.FirstName(fn.value, ...(fn.more ?? [])));
26
+ builder.add(typeof ln === 'string' ? name_js_1.Name.last(ln) : new name_js_1.LastName(ln.father, ln.mother));
27
+ return builder.build(config);
28
+ }
29
+ catch (error) {
30
+ if (error instanceof error_js_1.NameError)
31
+ throw error;
32
+ throw new error_js_1.UnknownError({
33
+ source: String(data),
34
+ message: 'could not deserialize data',
35
+ origin: error instanceof Error ? error : new Error(String(error)),
36
+ });
37
+ }
38
+ }
39
+ exports.deserialize = deserialize;
@@ -90,12 +90,34 @@ class FullName {
90
90
  this.#suffix = name_js_1.Name.suffix(name instanceof name_js_1.Name ? name.value : name);
91
91
  return this;
92
92
  }
93
- has(namon) {
93
+ has(key) {
94
+ const namon = typeof key === 'string' ? types_js_1.Namon.cast(key) : key;
95
+ if (!namon)
96
+ return false;
94
97
  if (namon.equal(types_js_1.Namon.PREFIX))
95
98
  return !!this.#prefix;
96
99
  if (namon.equal(types_js_1.Namon.SUFFIX))
97
100
  return !!this.#suffix;
98
101
  return namon.equal(types_js_1.Namon.MIDDLE_NAME) ? this.#middleName.length > 0 : true;
99
102
  }
103
+ *toIterable(flat = false) {
104
+ if (this.#prefix)
105
+ yield this.#prefix;
106
+ if (flat) {
107
+ yield* this.#firstName.asNames;
108
+ yield* this.#middleName;
109
+ yield* this.#lastName.asNames;
110
+ }
111
+ else {
112
+ yield this.#firstName;
113
+ yield* this.#middleName;
114
+ yield this.#lastName;
115
+ }
116
+ if (this.#suffix)
117
+ yield this.#suffix;
118
+ }
119
+ *[Symbol.iterator]() {
120
+ yield* this.toIterable(true);
121
+ }
100
122
  }
101
123
  exports.FullName = FullName;
package/dist/cjs/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./builder.js"), exports);
23
23
  __exportStar(require("./config.js"), exports);
24
24
  var constants_js_1 = require("./constants.js");
25
25
  Object.defineProperty(exports, "version", { enumerable: true, get: function () { return constants_js_1.VERSION; } });
26
+ __exportStar(require("./data.js"), exports);
26
27
  __exportStar(require("./error.js"), exports);
27
28
  __exportStar(require("./fullname.js"), exports);
28
29
  __exportStar(require("./name.js"), exports);
package/dist/cjs/name.js CHANGED
@@ -167,7 +167,7 @@ class LastName extends Name {
167
167
  return this.mother ?? '';
168
168
  case types_js_1.Surname.HYPHENATED:
169
169
  return this.hasMother ? `${this.value}-${this.#mother}` : this.value;
170
- case types_js_1.Surname.ALL:
170
+ default:
171
171
  return this.hasMother ? `${this.value} ${this.#mother}` : this.value;
172
172
  }
173
173
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Namefully = void 0;
4
4
  const constants_js_1 = require("./constants.js");
5
- const error_js_1 = require("./error.js");
6
5
  const name_js_1 = require("./name.js");
7
- const types_js_1 = require("./types.js");
6
+ const error_js_1 = require("./error.js");
8
7
  const utils_js_1 = require("./utils.js");
8
+ const types_js_1 = require("./types.js");
9
9
  const parser_js_1 = require("./parser.js");
10
10
  class Namefully {
11
11
  #fullName;
@@ -65,25 +65,43 @@ class Namefully {
65
65
  get salutation() {
66
66
  return this.format('p l');
67
67
  }
68
+ get parts() {
69
+ return this.#fullName.toIterable();
70
+ }
71
+ get size() {
72
+ return Array.from(this.parts).length;
73
+ }
74
+ *[Symbol.iterator]() {
75
+ yield* this.#fullName.toIterable(true);
76
+ }
68
77
  toString() {
69
78
  return this.full;
70
79
  }
71
- get(namon) {
72
- if (namon.equal(types_js_1.Namon.PREFIX))
80
+ get(key) {
81
+ const namon = typeof key === 'string' ? types_js_1.Namon.cast(key) : key;
82
+ if (namon?.equal(types_js_1.Namon.PREFIX))
73
83
  return this.#fullName.prefix;
74
- if (namon.equal(types_js_1.Namon.FIRST_NAME))
84
+ if (namon?.equal(types_js_1.Namon.FIRST_NAME))
75
85
  return this.#fullName.firstName;
76
- if (namon.equal(types_js_1.Namon.MIDDLE_NAME))
86
+ if (namon?.equal(types_js_1.Namon.MIDDLE_NAME))
77
87
  return this.#fullName.middleName;
78
- if (namon.equal(types_js_1.Namon.LAST_NAME))
88
+ if (namon?.equal(types_js_1.Namon.LAST_NAME))
79
89
  return this.#fullName.lastName;
80
- if (namon.equal(types_js_1.Namon.SUFFIX))
90
+ if (namon?.equal(types_js_1.Namon.SUFFIX))
81
91
  return this.#fullName.suffix;
82
92
  return undefined;
83
93
  }
84
94
  equal(other) {
85
95
  return this.toString() === other.toString();
86
96
  }
97
+ deepEqual(other) {
98
+ const others = Array.from(other.parts);
99
+ for (const part of this.parts) {
100
+ if (!others.some((name) => name.equal(part)))
101
+ return false;
102
+ }
103
+ return true;
104
+ }
87
105
  toJson() {
88
106
  return {
89
107
  prefix: this.prefix,
@@ -182,7 +200,7 @@ class Namefully {
182
200
  case types_js_1.Flat.MID_LAST:
183
201
  name = hasMid ? [fn, m, l] : [fn, l];
184
202
  break;
185
- case types_js_1.Flat.ALL:
203
+ default:
186
204
  name = hasMid ? [f, m, l] : [f, l];
187
205
  break;
188
206
  }
@@ -204,7 +222,7 @@ class Namefully {
204
222
  case types_js_1.Flat.MID_LAST:
205
223
  name = hasMid ? [l, fn, m] : [l, fn];
206
224
  break;
207
- case types_js_1.Flat.ALL:
225
+ default:
208
226
  name = hasMid ? [l, f, m] : [l, f];
209
227
  break;
210
228
  }
@@ -245,7 +263,7 @@ class Namefully {
245
263
  let group = '';
246
264
  const formatted = [];
247
265
  for (const char of pattern) {
248
- if (constants_js_1.ALLOWED_FORMAT_TOKENS.indexOf(char) === -1) {
266
+ if (!constants_js_1.ALLOWED_FORMAT_TOKENS.includes(char)) {
249
267
  throw new error_js_1.NotAllowedError({
250
268
  source: this.full,
251
269
  operation: 'format',
@@ -317,12 +335,6 @@ class Namefully {
317
335
  }
318
336
  #map(char) {
319
337
  switch (char) {
320
- case '.':
321
- case ',':
322
- case ' ':
323
- case '-':
324
- case '_':
325
- return char;
326
338
  case 'b':
327
339
  return this.birth;
328
340
  case 'B':
@@ -364,18 +376,42 @@ class Namefully {
364
376
  case 'S':
365
377
  return this.suffix?.toUpperCase();
366
378
  case '$f':
367
- case '$F':
368
379
  return this.#fullName.firstName.value[0];
380
+ case '$F':
381
+ return this.#fullName.firstName.initials(true).join('');
369
382
  case '$l':
370
- case '$L':
371
383
  return this.#fullName.lastName.value[0];
384
+ case '$L':
385
+ return this.#fullName.lastName.initials().join('');
372
386
  case '$m':
373
- case '$M':
374
387
  return this.hasMiddle ? this.middle[0] : undefined;
388
+ case '$M':
389
+ return this.hasMiddle ? this.#fullName.middleName.map((n) => n.value[0]).join('') : undefined;
375
390
  default:
376
- return undefined;
391
+ return constants_js_1.ALLOWED_FORMAT_TOKENS.includes(char) ? char : undefined;
377
392
  }
378
393
  }
394
+ serialize() {
395
+ const { config, firstName: fn, lastName: ln } = this.#fullName;
396
+ return {
397
+ names: {
398
+ prefix: this.prefix,
399
+ firstName: fn.hasMore ? { value: fn.value, more: fn.more } : fn.value,
400
+ middleName: this.hasMiddle ? this.middleName() : undefined,
401
+ lastName: ln.hasMother ? { father: ln.father, mother: ln.mother } : ln.value,
402
+ suffix: this.suffix,
403
+ },
404
+ config: {
405
+ name: config.name,
406
+ orderedBy: config.orderedBy,
407
+ separator: config.separator.token,
408
+ title: config.title,
409
+ ending: config.ending,
410
+ bypass: config.bypass,
411
+ surname: config.surname,
412
+ },
413
+ };
414
+ }
379
415
  }
380
416
  exports.Namefully = Namefully;
381
417
  exports.default = (names, options) => {
@@ -123,8 +123,8 @@ class ArrayNameParser extends Parser {
123
123
  fullName.middleName.push(name);
124
124
  }
125
125
  else if (name.isLastName) {
126
- const lastName = new name_js_1.LastName(name.value, name instanceof name_js_1.LastName ? name.mother : undefined, config.surname);
127
- fullName.setLastName(lastName);
126
+ const mother = name instanceof name_js_1.LastName ? name.mother : undefined;
127
+ fullName.setLastName(new name_js_1.LastName(name.value, mother, config.surname));
128
128
  }
129
129
  }
130
130
  return fullName;
package/dist/cjs/types.js CHANGED
@@ -56,6 +56,13 @@ class Namon {
56
56
  [Namon.LAST_NAME.key, Namon.LAST_NAME],
57
57
  [Namon.SUFFIX.key, Namon.SUFFIX],
58
58
  ]);
59
+ static aliases = {
60
+ [Namon.PREFIX.key]: ['prefix', 'px', 'p'],
61
+ [Namon.FIRST_NAME.key]: ['firstname', 'first', 'fn', 'f'],
62
+ [Namon.MIDDLE_NAME.key]: ['middlename', 'middle', 'mid', 'mn', 'm'],
63
+ [Namon.LAST_NAME.key]: ['lastname', 'last', 'ln', 'l'],
64
+ [Namon.SUFFIX.key]: ['suffix', 'sx', 's'],
65
+ };
59
66
  constructor(index, key) {
60
67
  this.index = index;
61
68
  this.key = key;
@@ -64,7 +71,9 @@ class Namon {
64
71
  return Namon.all.has(key);
65
72
  }
66
73
  static cast(key) {
67
- return Namon.has(key) ? Namon.all.get(key) : undefined;
74
+ const searchValue = String(key).toLowerCase();
75
+ const namon = Object.entries(Namon.aliases).find(([, list]) => list.includes(searchValue))?.[0];
76
+ return Namon.has(namon ?? '') ? Namon.all.get(key) : undefined;
68
77
  }
69
78
  toString() {
70
79
  return `Namon.${this.key}`;
@@ -104,6 +113,14 @@ class Separator {
104
113
  this.name = name;
105
114
  this.token = token;
106
115
  }
116
+ static cast(key) {
117
+ for (const [name, separator] of Separator.all) {
118
+ if (separator.token === key || name.toLowerCase() === key.toLowerCase()) {
119
+ return separator;
120
+ }
121
+ }
122
+ return undefined;
123
+ }
107
124
  toString() {
108
125
  return `Separator.${this.name}`;
109
126
  }
@@ -1,6 +1,6 @@
1
1
  import { Name } from './name.js';
2
2
  import { Config } from './config.js';
3
- import { Namefully } from './namefully.js';
3
+ import { Namefully, NameOptions } from './namefully.js';
4
4
  type VoidCallback = () => void;
5
5
  type Callback<Type, Return> = (value: Type) => Return;
6
6
  /**
@@ -70,6 +70,6 @@ export declare class NameBuilder extends Builder<Name, Namefully> {
70
70
  * Regardless of how the names are added, both first and last names must exist
71
71
  * to complete a fine build. Otherwise, it throws a NameError.
72
72
  */
73
- build(config?: Partial<Config>): Namefully;
73
+ build(options?: NameOptions): Namefully;
74
74
  }
75
75
  export {};
@@ -1,5 +1,5 @@
1
- import { Namefully } from './namefully.js';
2
1
  import { ArrayNameValidator } from './validator.js';
2
+ import { Namefully } from './namefully.js';
3
3
  class Builder {
4
4
  prebuild;
5
5
  postbuild;
@@ -67,11 +67,11 @@ export class NameBuilder extends Builder {
67
67
  static use({ names, prebuild, postbuild, preclear, postclear, }) {
68
68
  return new NameBuilder(names ?? [], prebuild, postbuild, preclear, postclear);
69
69
  }
70
- build(config) {
70
+ build(options) {
71
71
  this.prebuild?.();
72
72
  const names = [...this.queue];
73
73
  ArrayNameValidator.create().validate(names);
74
- this.instance = new Namefully(names, config);
74
+ this.instance = new Namefully(names, options);
75
75
  this.postbuild?.(this.instance);
76
76
  return this.instance;
77
77
  }
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "2.0.2";
1
+ export declare const VERSION = "2.1.0";
2
2
  export declare const MIN_NUMBER_OF_NAME_PARTS = 2;
3
3
  export declare const MAX_NUMBER_OF_NAME_PARTS = 5;
4
- export declare const ALLOWED_FORMAT_TOKENS: string[];
4
+ export declare const ALLOWED_FORMAT_TOKENS = " .,_-()[]<>'\"bBfFlLmMnNoOpPsS$";
@@ -1,27 +1,4 @@
1
- export const VERSION = '2.0.2';
1
+ export const VERSION = '2.1.0';
2
2
  export const MIN_NUMBER_OF_NAME_PARTS = 2;
3
3
  export const MAX_NUMBER_OF_NAME_PARTS = 5;
4
- export const ALLOWED_FORMAT_TOKENS = [
5
- '.',
6
- ',',
7
- ' ',
8
- '-',
9
- '_',
10
- 'b',
11
- 'B',
12
- 'f',
13
- 'F',
14
- 'l',
15
- 'L',
16
- 'm',
17
- 'M',
18
- 'n',
19
- 'N',
20
- 'o',
21
- 'O',
22
- 'p',
23
- 'P',
24
- 's',
25
- 'S',
26
- '$',
27
- ];
4
+ export const ALLOWED_FORMAT_TOKENS = ` .,_-()[]<>'"bBfFlLmMnNoOpPsS$`;
@@ -0,0 +1,41 @@
1
+ import { type Namefully } from './namefully.js';
2
+ /** Serialized representation of a Namefully instance. */
3
+ export interface SerializedName {
4
+ /** The name data (with its hierarchy intact). */
5
+ names: {
6
+ prefix?: string;
7
+ firstName: string | {
8
+ value: string;
9
+ more?: string[];
10
+ };
11
+ middleName?: string[];
12
+ lastName: string | {
13
+ father: string;
14
+ mother?: string;
15
+ };
16
+ suffix?: string;
17
+ };
18
+ /** The configuration data. */
19
+ config: {
20
+ name: string;
21
+ orderedBy: string;
22
+ separator: string;
23
+ title: string;
24
+ ending: boolean;
25
+ bypass: boolean;
26
+ surname: string;
27
+ };
28
+ }
29
+ /**
30
+ * Deserializes a JSON object into a Namefully instance.
31
+ *
32
+ * This is the inverse operation of `serialize()`, reconstructing a Namefully
33
+ * instance from a previously serialized JSON object, preserving the name hierarchy.
34
+ *
35
+ * @param {SerializedName | string} data the serialized Namefully data (from `serialize()`
36
+ * or compatible format).
37
+ * @returns a new Namefully instance.
38
+ *
39
+ * @throws {NameError} if the data cannot be parsed or is invalid.
40
+ */
41
+ export declare function deserialize(data: SerializedName | string): Namefully;
@@ -0,0 +1,35 @@
1
+ import { NameBuilder } from './builder.js';
2
+ import { Name, FirstName, LastName } from './name.js';
3
+ import { InputError, NameError, UnknownError } from './error.js';
4
+ export function deserialize(data) {
5
+ try {
6
+ const parsed = typeof data === 'string' ? JSON.parse(data) : data;
7
+ if (!parsed || typeof parsed !== 'object') {
8
+ throw new InputError({
9
+ source: String(data),
10
+ message: 'invalid serialized data; must be an object or a string',
11
+ });
12
+ }
13
+ const { names, config } = parsed;
14
+ const { firstName: fn, lastName: ln, middleName: mn, prefix: px, suffix: sx } = names;
15
+ const builder = NameBuilder.of();
16
+ if (px)
17
+ builder.add(Name.prefix(px));
18
+ if (sx)
19
+ builder.add(Name.suffix(sx));
20
+ if (mn)
21
+ builder.add(...mn.map((n) => Name.middle(n)));
22
+ builder.add(typeof fn === 'string' ? Name.first(fn) : new FirstName(fn.value, ...(fn.more ?? [])));
23
+ builder.add(typeof ln === 'string' ? Name.last(ln) : new LastName(ln.father, ln.mother));
24
+ return builder.build(config);
25
+ }
26
+ catch (error) {
27
+ if (error instanceof NameError)
28
+ throw error;
29
+ throw new UnknownError({
30
+ source: String(data),
31
+ message: 'could not deserialize data',
32
+ origin: error instanceof Error ? error : new Error(String(error)),
33
+ });
34
+ }
35
+ }
@@ -48,5 +48,9 @@ export declare class FullName {
48
48
  setMiddleName(names: string[] | Name[]): FullName;
49
49
  setSuffix(name: Nullable<string | Name>): FullName;
50
50
  /** Returns true if a namon has been set. */
51
- has(namon: Namon): boolean;
51
+ has(key: Namon | string): boolean;
52
+ /** Returns an `Iterable` of existing `Name`s. */
53
+ toIterable(flat?: boolean): Iterable<Name>;
54
+ /** Returns the default iterator for this name set (enabling for-of statements). */
55
+ [Symbol.iterator](): Iterator<Name>;
52
56
  }
@@ -87,11 +87,33 @@ export class FullName {
87
87
  this.#suffix = Name.suffix(name instanceof Name ? name.value : name);
88
88
  return this;
89
89
  }
90
- has(namon) {
90
+ has(key) {
91
+ const namon = typeof key === 'string' ? Namon.cast(key) : key;
92
+ if (!namon)
93
+ return false;
91
94
  if (namon.equal(Namon.PREFIX))
92
95
  return !!this.#prefix;
93
96
  if (namon.equal(Namon.SUFFIX))
94
97
  return !!this.#suffix;
95
98
  return namon.equal(Namon.MIDDLE_NAME) ? this.#middleName.length > 0 : true;
96
99
  }
100
+ *toIterable(flat = false) {
101
+ if (this.#prefix)
102
+ yield this.#prefix;
103
+ if (flat) {
104
+ yield* this.#firstName.asNames;
105
+ yield* this.#middleName;
106
+ yield* this.#lastName.asNames;
107
+ }
108
+ else {
109
+ yield this.#firstName;
110
+ yield* this.#middleName;
111
+ yield this.#lastName;
112
+ }
113
+ if (this.#suffix)
114
+ yield this.#suffix;
115
+ }
116
+ *[Symbol.iterator]() {
117
+ yield* this.toIterable(true);
118
+ }
97
119
  }
@@ -15,6 +15,7 @@ import namefully from './namefully.js';
15
15
  export * from './builder.js';
16
16
  export * from './config.js';
17
17
  export { VERSION as version } from './constants.js';
18
+ export * from './data.js';
18
19
  export * from './error.js';
19
20
  export * from './fullname.js';
20
21
  export * from './name.js';
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import namefully from './namefully.js';
2
2
  export * from './builder.js';
3
3
  export * from './config.js';
4
4
  export { VERSION as version } from './constants.js';
5
+ export * from './data.js';
5
6
  export * from './error.js';
6
7
  export * from './fullname.js';
7
8
  export * from './name.js';
@@ -80,14 +80,14 @@ export declare class FirstName extends Name {
80
80
  /** Representation of a last name with some extra functionality. */
81
81
  export declare class LastName extends Name {
82
82
  #private;
83
- readonly format: Surname;
83
+ readonly format: Surname | 'father' | 'mother' | 'hyphenated' | 'all';
84
84
  /**
85
85
  * Creates an extended version of `Name` and flags it as a last name `type`.
86
86
  *
87
87
  * Some people may keep their @param mother's surname and want to keep a clear cut
88
88
  * from their @param father's surname. However, there are no clear rules about it.
89
89
  */
90
- constructor(father: string, mother?: string, format?: Surname);
90
+ constructor(father: string, mother?: string, format?: Surname | 'father' | 'mother' | 'hyphenated' | 'all');
91
91
  /** The surname inherited from the father side. */
92
92
  get father(): string;
93
93
  /** The surname inherited from the mother side. */
@@ -97,8 +97,8 @@ export declare class LastName extends Name {
97
97
  get length(): number;
98
98
  /** Returns a combined version of the `father` and `mother` if any. */
99
99
  get asNames(): Name[];
100
- toString(format?: Surname): string;
101
- initials(format?: Surname): string[];
100
+ toString(format?: Surname | 'father' | 'mother' | 'hyphenated' | 'all'): string;
101
+ initials(format?: Surname | 'father' | 'mother' | 'hyphenated' | 'all'): string[];
102
102
  caps(range?: CapsRange): LastName;
103
103
  decaps(range?: CapsRange): LastName;
104
104
  /** Makes a copy of the current name. */
package/dist/esm/name.js CHANGED
@@ -162,7 +162,7 @@ export class LastName extends Name {
162
162
  return this.mother ?? '';
163
163
  case Surname.HYPHENATED:
164
164
  return this.hasMother ? `${this.value}-${this.#mother}` : this.value;
165
- case Surname.ALL:
165
+ default:
166
166
  return this.hasMother ? `${this.value} ${this.#mother}` : this.value;
167
167
  }
168
168
  }