namefully 1.2.1 → 1.3.1

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,74 +1,76 @@
1
1
  import { Config } from './config';
2
2
  import { Name, JsonName } from './name';
3
+ import { NameIndex } from './utils';
4
+ import { Flat, NameOrder, NameType, Namon, Nullable, Surname, Separator, Title } from './types';
3
5
  import { Parser } from './parser';
4
- import { Flat, NameOrder, NameType, Namon, Nullable, Surname } from './types';
5
6
  /**
6
- * A helper for organizing person names in a particular order, way, or shape.
7
+ * A utility for organizing human names in a particular order, way, or shape.
7
8
  *
8
- * Though `namefully` is easy to use, it does not magically guess which part of
9
- * the name is what (prefix, suffix, first, last, or middle names). It relies
10
- * actually on how the name parts are indicated (i.e., their roles) so that
11
- * it can perform internally certain operations and saves us some extra
12
- * calculations/processing. In addition, `Namefully` can be created using
13
- * distinct raw data shapes. This is intended to give some flexibility to the
14
- * developer so that he or she is not bound to a particular data format.
15
- * By following closely the API reference to know how to harness its usability,
16
- * this utility aims to save time in formatting names.
9
+ * Though `namefully` is designed to be easy to use, it does not magically guess
10
+ * which part of the name is what (prefix, suffix, first, last, or middle names).
11
+ * It relies actually on how the name parts are indicated (i.e., their roles)
12
+ * so that it can perform internally certain operations and saves us some extra
13
+ * calculations/processing. Additionally, `Namefully` objects may be created using
14
+ * distinct raw data shapes. This is intended to give some flexibility to you
15
+ * so that you are not bound to a particular data format (e.g., string).
16
+ * Follow the API reference to know how to harness its usability as this utility
17
+ * aims to save time in formatting names.
17
18
  *
18
- * `namefully` also works like a trapdoor. Once a raw data is provided and
19
- * validated, a developer can only *access* in a vast amount of, yet effective
20
- * ways the name info. *No editing* is possible. If the name is mistaken, a new
21
- * instance of `Namefully` must be created. In other words, it's immutable.
22
- * Remember, this utility's primary objective is to help manipulate a person name.
19
+ * `namefully` also works like a trapdoor. Once some name data is provided and
20
+ * validated, you may only *access* it but not update any part of it. This
21
+ * means that *no editing* is possible. If the name is mistaken, a new
22
+ * instance of `Namefully` must be created. In simple terms, it's immutable.
23
+ * Remember, this utility's primary objective is to help manipulate human names,
24
+ * not the opposite.
23
25
  *
24
- * Note that the name standards used for the current version of this library
25
- * are as follows:
26
+ * Note that the name standards used for the current version of this utility are
27
+ * as follows:
26
28
  * `[prefix] firstName [middleName] lastName [suffix]`
27
- * The opening `[` and closing `]` symbols mean that these parts are optional.
29
+ * where the opening `[` and closing `]` brackets mean that these parts are optional.
28
30
  * In other words, the most basic and typical case is a name that looks like
29
31
  * this: `John Smith`, where `John` is the first name piece and `Smith`, the last
30
32
  * name piece.
31
33
  *
32
- * @see https://departments.weber.edu/qsupport&training/Data_Standards/Name.htm
33
- * for more info on name standards.
34
+ * @see {@link https://www.fbiic.gov/public/2008/nov/Naming_practice_guide_UK_2006.pdf} for
35
+ * more info on name standards.
34
36
  *
35
37
  * **IMPORTANT**: Keep in mind that the order of appearance (or name order) matters
36
- * and may be altered through configured parameters, which will be seen later.
38
+ * and may be altered through configurable parameters, which will be seen later.
37
39
  * By default, the order of appearance is as shown above and will be used as a
38
40
  * basis for future examples and use cases.
39
41
  *
40
- * Once imported, all that is required to do is to create an instance of
41
- * `Namefully` and the rest will follow.
42
+ * Once imported, all that is required to do is to create instances of `Namefully`
43
+ * as you see fit and the rest will follow.
42
44
  *
43
45
  * Some terminologies used across the library are:
44
- * - namon: 1 piece of name (e.g., first name)
45
- * - nama: 2+ pieces of name (e.g., first name + last name)
46
+ * - namon: 1 piece of name (e.g., prefix)
47
+ * - nama: a combination of 2+ pieces of name (e.g., first name + last name)
46
48
  *
47
49
  * Happy name handling 😊!
48
50
  */
49
51
  export declare class Namefully {
50
52
  #private;
51
53
  /**
52
- * Creates a name with distinguishable parts from a raw string content.
54
+ * Creates a name with distinguishable parts.
53
55
  * @param names element to parse.
54
56
  * @param options additional settings.
55
57
  *
56
- * An optional configuration may be provided with specifics on how to treat
57
- * a full name during its course. By default, all name parts are validated
58
- * against some basic validation rules to avoid common runtime exceptions.
58
+ * Optional parameters may be provided with specifics on how to treat a full
59
+ * name during its existence. All name parts must have at least one (1) character
60
+ * to proceed. That is the only requirement/validation of namefully.
59
61
  */
60
- constructor(names: string | string[] | Name[] | JsonName | Parser, options?: Partial<Config>);
62
+ constructor(names: string | string[] | Name[] | JsonName | Parser, options?: NameOptions);
61
63
  /**
62
64
  * Constructs a `Namefully` instance from a text.
63
65
  *
64
- * It works like `parse` except that this function returns `null` where `parse`
65
- * would throw a `NameError`.
66
+ * It works like `parse` except that this function returns `undefined` when
67
+ * `parse` would throw a `NameError`.
66
68
  */
67
- static tryParse(text: string): Namefully | undefined;
69
+ static tryParse(text: string, index?: NameIndex): Namefully | undefined;
68
70
  /**
69
71
  * Constructs a `Namefully` instance from a text.
70
72
  *
71
- * It throws a `NameError` if the text cannot be parsed. Use `tryParse`
73
+ * @throws a `NameError` if the @param text cannot be parsed. Use `tryParse`
72
74
  * instead if a `null` return is preferred over a throwable error.
73
75
  *
74
76
  * This operation is computed asynchronously, which gives more flexibility at
@@ -80,119 +82,143 @@ export declare class Namefully {
80
82
  * Keep in mind that prefix and suffix are not considered during the parsing
81
83
  * process.
82
84
  */
83
- static parse(text: string): Promise<Namefully>;
84
- /** The current configuration. */
85
+ static parse(text: string, index?: NameIndex): Promise<Namefully>;
86
+ /** The configuration dictating this name's behavior. */
85
87
  get config(): Config;
86
88
  /** The number of characters of the `birthName`, including spaces. */
87
89
  get length(): number;
88
- /** The prefix part. */
89
- get prefix(): Nullable<string>;
90
- /** The firt name part. */
90
+ /** The prefix part of the name set. */
91
+ get prefix(): string | undefined;
92
+ /** The firt name part of the name set. */
91
93
  get first(): string;
92
- /** The first middle name part if any. */
93
- get middle(): Nullable<string>;
94
+ /** The first middle name part of the name set if any. */
95
+ get middle(): string | undefined;
94
96
  /** Returns true if any middle name has been set. */
95
97
  get hasMiddle(): boolean;
96
- /** The last name part. */
98
+ /** The last name part of the name set. */
97
99
  get last(): string;
98
- /** The suffix part. */
99
- get suffix(): Nullable<string>;
100
- /** The birth name part. */
100
+ /** The suffix part of the name set. */
101
+ get suffix(): string | undefined;
102
+ /** The birth name part of the name set. */
101
103
  get birth(): string;
102
- /** The shortest version of a person name. */
104
+ /** The shortest version of a human name (first + last name). */
103
105
  get short(): string;
104
- /** The longest version of a person name. */
106
+ /** The longest version of a human name (a.k.a birth name). */
105
107
  get long(): string;
106
108
  /** The entire name set. */
107
109
  get full(): string;
108
110
  /** The first name combined with the last name's initial. */
109
111
  get public(): string;
110
- /** Returns the full name as set. */
112
+ /** The combination of prefix and last name. */
113
+ get salutation(): string;
114
+ /**
115
+ * Returns an iterable of the name components in their natural form.
116
+ *
117
+ * Regardless of the order of appearance, this method will always return the
118
+ * existing `Name`s according to the name standards upon which this library
119
+ * is based.
120
+ *
121
+ * This is useful for iterating over the name parts in a consistent manner and
122
+ * this automatically enables operations such as mapping, filtering, etc.
123
+ */
124
+ get parts(): Iterable<Name>;
125
+ /** The number of name components. */
126
+ get size(): number;
127
+ /**
128
+ * Makes the name set iterable (i.e., for-of statements).
129
+ *
130
+ * This is similar to `parts` with the exception that all name components are
131
+ * returned as `Name` classes (instead of their natural form - e.g., `FirstName`)
132
+ * to maintain certain homogeneity and consistency across each name piece.
133
+ */
134
+ [Symbol.iterator](): Iterator<Name>;
135
+ /** Gets a string representation of the full name. */
111
136
  toString(): string;
112
137
  /** Fetches the raw form of a name piece. */
113
- get(namon: Namon): Nullable<Name | Name[]>;
138
+ get(key: Namon | string): Nullable<Name | Name[]>;
114
139
  /** Whether this name is equal to another one from a raw-string perspective. */
115
140
  equal(other: Namefully): boolean;
141
+ /** Whether this name is equal to another one from a component perspective. */
142
+ deepEqual(other: Namefully): boolean;
116
143
  /** Gets a JSON representation of the full name. */
117
144
  toJson(): JsonName;
118
- /** Confirms that a name part has been set. */
119
- has(namon: Namon): boolean;
145
+ json: () => JsonName;
146
+ /** Confirms whether a name component exists. */
147
+ has(namon: Namon | string): boolean;
120
148
  /**
121
149
  * Gets the full name ordered as configured.
122
150
  *
123
- * The name order `orderedBy` forces to order by first or last name by
124
- * overriding the preset configuration.
125
- *
126
- * `Namefully.format` may also be used to alter manually the order of appearance
127
- * of full name.
151
+ * @param {NameOrder} orderedBy forces to arrange a name set by first or last
152
+ * name, overriding the preset configuration.
128
153
  *
129
- * For example:
154
+ * `Namefully.format()` may also be used to alter manually the order of appearance
155
+ * of a full name. For example:
130
156
  * ```ts
131
157
  * const name = new Namefully('Jon Stark Snow');
132
158
  * console.log(name.fullName(NameOrder.LAST_NAME)); // "Snow Jon Stark"
133
159
  * console.log(name.format('l f m')); // "Snow Jon Stark"
134
160
  * ```
135
161
  */
136
- fullName(orderedBy?: NameOrder): string;
162
+ fullName(orderedBy?: NameOptions['orderedBy']): string;
137
163
  /**
138
164
  * Gets the birth name ordered as configured, no `prefix` or `suffix`.
139
165
  *
140
166
  * @param orderedBy forces to order by first or last name by overriding the
141
167
  * preset configuration.
142
168
  */
143
- birthName(orderedBy?: NameOrder): string;
169
+ birthName(orderedBy?: NameOptions['orderedBy']): string;
144
170
  /**
145
171
  * Gets the first name part of the `FullName`.
146
- *
147
- * @param withMore determines whether to include other pieces of the first
148
- * name.
172
+ * @param {boolean} withMore determines whether to include other pieces of the
173
+ * first name.
149
174
  */
150
175
  firstName(withMore?: boolean): string;
151
176
  /** Gets the middle name part of the `FullName`. */
152
177
  middleName(): string[];
153
178
  /**
154
179
  * Gets the last name part of the `FullName`.
155
- *
156
- * @param format overrides the how-to formatting of a surname output,
180
+ * @param {Surname} format overrides the how-to formatting of a surname output,
157
181
  * considering its sub-parts.
158
182
  */
159
- lastName(format?: Surname): string;
183
+ lastName(format?: NameOptions['surname']): string;
160
184
  /**
161
185
  * Gets the initials of the `FullName`.
162
186
  *
163
- * @param {options.orderedBy} forces to order by first or last name by
187
+ * @param {object} options when getting the initials.
188
+ * @param {NameOrder} options.orderedBy forces to order by first or last name by
164
189
  * overriding the preset configuration.
165
- * @param
190
+ * @param {NameType} options.only selects initials of only certain name parts.
191
+ * @param {boolean} options.asJson whether to return initials as an array or JSON.
166
192
  *
167
193
  * For example, given the names:
168
194
  * - `John Smith` => `['J', 'S']`
169
195
  * - `John Ben Smith` => `['J', 'B', 'S']`.
170
196
  */
171
197
  initials(options?: {
172
- orderedBy?: NameOrder;
173
- only?: NameType;
174
- }): string[];
198
+ orderedBy?: NameOptions['orderedBy'];
199
+ only?: NameType | 'firstName' | 'lastName' | 'middleName' | 'birthName';
200
+ asJson?: boolean;
201
+ }): string[] | Record<string, string[]>;
175
202
  /**
176
203
  * Shortens a complex full name to a simple typical name, a combination of
177
204
  * first and last name.
178
205
  *
179
- * @param orderedBy forces to order by first or last name by overriding the
180
- * preset configuration.
206
+ * @param {NameOrder} orderedBy forces to order by first or last name, overriding
207
+ * the preset configuration.
181
208
  *
182
209
  * For a given name such as `Mr Keanu Charles Reeves`, shortening this name
183
210
  * is equivalent to making it `Keanu Reeves`.
184
211
  *
185
212
  * As a shortened name, the namon of the first name is favored over the other
186
- * names forming part of the entire first names, if any. Meanwhile, for
187
- * the last name, the configured `surname` is prioritized.
213
+ * names forming part of the entire first names, if any. Meanwhile, for the
214
+ * last name, the configured `surname` is prioritized.
188
215
  *
189
216
  * For a given `FirstName FatherName MotherName`, shortening this name when
190
- * the surname is set as `mother` is equivalent to making it:
191
- * `FirstName MotherName`.
217
+ * the surname is set as `mother` is equivalent to making it: `FirstName MotherName`.
192
218
  */
193
- shorten(orderedBy?: NameOrder): string;
219
+ shorten(orderedBy?: NameOptions['orderedBy']): string;
194
220
  /**
195
- * Flattens a long name using the name types as variants.
221
+ * Flattens long names using the name types as variants.
196
222
  *
197
223
  * While @param limit sets a threshold as a limited number of characters
198
224
  * supported to flatten a `FullName`, @param by indicates which variant
@@ -226,17 +252,16 @@ export declare class Namefully {
226
252
  withPeriod: boolean;
227
253
  recursive: boolean;
228
254
  withMore: boolean;
229
- surname: Surname;
255
+ surname: NameOptions['surname'];
230
256
  }>): string;
231
257
  /**
232
258
  * Zips or compacts a name using different forms of variants.
233
- *
234
259
  * @see `flatten()` for more details.
235
260
  */
236
261
  zip(by?: Flat, withPeriod?: boolean): string;
237
262
  /**
238
263
  * Formats the full name as desired.
239
- * @param pattern character used to format it.
264
+ * @param {string} pattern character used to format it.
240
265
  *
241
266
  * string format
242
267
  * -------------
@@ -261,14 +286,6 @@ export declare class Namefully {
261
286
  * - 'P': capitalized prefix
262
287
  * - 's': suffix
263
288
  * - 'S': capitalized suffix
264
- *
265
- * punctuations
266
- * ------------
267
- * - '.': period
268
- * - ',': comma
269
- * - ' ': space
270
- * - '-': hyphen
271
- * - '_': underscore
272
289
  * - '$': an escape character to select only the initial of the next char.
273
290
  *
274
291
  * Given the name `Joe Jim Smith`, use `format` with the `pattern` string.
@@ -282,7 +299,7 @@ export declare class Namefully {
282
299
  * first, middle, and last names.
283
300
  */
284
301
  format(pattern: string): string;
285
- /** Flips definitely the name order from the preset/current config. */
302
+ /** Flips or swaps the name order from the preset/current config. */
286
303
  flip(): void;
287
304
  /**
288
305
  * Splits the name parts of a birth name.
@@ -291,7 +308,7 @@ export declare class Namefully {
291
308
  split(separator?: string | RegExp): string[];
292
309
  /**
293
310
  * Joins the name parts of a birth name.
294
- * @param separator token for the junction.
311
+ * @param {string} separator token for the junction.
295
312
  */
296
313
  join(separator?: string): string;
297
314
  /** Transforms a birth name into UPPERCASE. */
@@ -311,3 +328,20 @@ export declare class Namefully {
311
328
  /** Transforms a birth name into ToGgLeCaSe. */
312
329
  toToggleCase(): string;
313
330
  }
331
+ /**
332
+ * A default export for the `namefully` utility.
333
+ * @param names element to parse.
334
+ * @param options additional settings.
335
+ */
336
+ declare const _default: (names: string | string[] | Name[] | JsonName | Parser, options?: NameOptions) => Namefully;
337
+ export default _default;
338
+ /** Optional namefully parameters (@see {@linkcode Config} for more details). */
339
+ export type NameOptions = Partial<{
340
+ name: string;
341
+ orderedBy: NameOrder | 'firstName' | 'lastName';
342
+ separator: Separator;
343
+ title: Title | 'UK' | 'US';
344
+ ending: boolean;
345
+ bypass: boolean;
346
+ surname: Surname | 'father' | 'mother' | 'hyphenated' | 'all';
347
+ }>;
@@ -1,10 +1,11 @@
1
- import { FullName } from './full-name';
2
1
  import { Config } from './config';
2
+ import { NameIndex } from './utils';
3
+ import { FullName } from './full-name';
3
4
  import { Name, JsonName } from './name';
4
5
  /**
5
6
  * A parser signature that helps to organize the names accordingly.
6
7
  */
7
- export declare abstract class Parser<T = any> {
8
+ export declare abstract class Parser<T = unknown> {
8
9
  raw: T;
9
10
  /**
10
11
  * Constructs a custom parser accordingly.
@@ -12,19 +13,17 @@ export declare abstract class Parser<T = any> {
12
13
  */
13
14
  constructor(raw: T);
14
15
  /**
15
- * Builds a dynamic `Parser` on the fly and throws a `NameError` when unable
16
- * to do so. The built parser only knows how to operate birth names.
17
- */
18
- static build(text: string): Parser;
19
- /**
20
- * Builds asynchronously a dynamic `Parser`.
16
+ * Parses raw data into a `FullName` while applying some options.
17
+ * @param options for additional configuration to apply.
21
18
  */
22
- static buildAsync(text: string): Promise<Parser>;
19
+ abstract parse(options?: Partial<Config>): FullName;
23
20
  /**
24
- * Parses the raw data into a `FullName` while considering some options.
25
- * @param options additional configuration to apply.
21
+ * Builds a dynamic `Parser` on the fly and throws a `NameError` when unable
22
+ * to do so. The built parser only knows how to operate birth names.
26
23
  */
27
- abstract parse(options?: Partial<Config>): FullName;
24
+ static build(text: string, index?: NameIndex): Parser;
25
+ /** Builds asynchronously a dynamic `Parser`. */
26
+ static buildAsync(text: string, index?: NameIndex): Promise<Parser>;
28
27
  }
29
28
  export declare class StringParser extends Parser<string> {
30
29
  parse(options: Partial<Config>): FullName;
@@ -33,7 +32,6 @@ export declare class ArrayStringParser extends Parser<string[]> {
33
32
  parse(options: Partial<Config>): FullName;
34
33
  }
35
34
  export declare class NamaParser extends Parser<JsonName> {
36
- #private;
37
35
  parse(options: Partial<Config>): FullName;
38
36
  }
39
37
  export declare class ArrayNameParser extends Parser<Name[]> {
@@ -1,6 +1,4 @@
1
- /**
2
- * Make a type nullable.
3
- */
1
+ /** Make a type nullable. */
4
2
  export type Nullable<T> = T | null | undefined;
5
3
  /**
6
4
  * The abbreviation type to indicate whether or not to add period to a prefix
@@ -23,25 +21,19 @@ export declare enum Surname {
23
21
  HYPHENATED = "hyphenated",
24
22
  ALL = "all"
25
23
  }
26
- /**
27
- * The order of appearance of a `FullName`.
28
- */
24
+ /** The order of appearance of a `FullName`. */
29
25
  export declare enum NameOrder {
30
26
  FIRST_NAME = "firstName",
31
27
  LAST_NAME = "lastName"
32
28
  }
33
- /**
34
- * The types of name handled in this according the name standards.
35
- */
29
+ /** The types of name handled in this according the name standards. */
36
30
  export declare enum NameType {
37
31
  FIRST_NAME = "firstName",
38
32
  MIDDLE_NAME = "middleName",
39
33
  LAST_NAME = "lastName",
40
34
  BIRTH_NAME = "birthName"
41
35
  }
42
- /**
43
- * The possible variants to indicate how to flatten a `FullName`.
44
- */
36
+ /** The possible variants to indicate how to flatten a `FullName`. */
45
37
  export declare enum Flat {
46
38
  FIRST_NAME = "firstName",
47
39
  MIDDLE_NAME = "middleName",
@@ -50,17 +42,13 @@ export declare enum Flat {
50
42
  MID_LAST = "midLast",
51
43
  ALL = "all"
52
44
  }
53
- /**
54
- * The range to use when capitalizing a string content.
55
- */
45
+ /** The range to use when capitalizing a string content. */
56
46
  export declare enum CapsRange {
57
47
  NONE = 0,
58
48
  INITIAL = 1,
59
49
  ALL = 2
60
50
  }
61
- /**
62
- * The types of name handled in this utility according the name standards.
63
- */
51
+ /** The types of name handled in this utility according the name standards. */
64
52
  export declare class Namon {
65
53
  readonly index: number;
66
54
  readonly key: string;
@@ -69,35 +57,22 @@ export declare class Namon {
69
57
  static readonly MIDDLE_NAME: Namon;
70
58
  static readonly LAST_NAME: Namon;
71
59
  static readonly SUFFIX: Namon;
72
- /**
73
- * The list of supported name types.
74
- */
60
+ /** The list of supported name types. */
75
61
  static readonly values: Namon[];
76
- /**
77
- * All the predefined name types.
78
- */
62
+ /** All the predefined name types. */
79
63
  static readonly all: Map<string, Namon>;
64
+ private static readonly aliases;
80
65
  private constructor();
81
- /**
82
- * Whether this string key is part of the predefined keys.
83
- */
66
+ /** Whether this string key is part of the predefined keys. */
84
67
  static has(key: string): boolean;
85
- /**
86
- * Makes a string key a namon type.
87
- */
68
+ /** Makes a string key a namon type. */
88
69
  static cast(key: string): Nullable<Namon>;
89
- /**
90
- * String representation of this object.
91
- */
70
+ /** String representation of this object. */
92
71
  toString(): string;
93
- /**
94
- * Whether this and the other value are equal.
95
- */
72
+ /** Whether this and the other value are equal. */
96
73
  equal(other: Namon | unknown): boolean;
97
74
  }
98
- /**
99
- * The token used to indicate how to split string values.
100
- */
75
+ /** The token used to indicate how to split string values. */
101
76
  export declare class Separator {
102
77
  readonly name: string;
103
78
  readonly token: string;
@@ -111,17 +86,13 @@ export declare class Separator {
111
86
  static readonly SINGLE_QUOTE: Separator;
112
87
  static readonly SPACE: Separator;
113
88
  static readonly UNDERSCORE: Separator;
114
- /**
115
- * All the available separators.
116
- */
89
+ /** All the available separators. */
117
90
  static readonly all: Map<string, Separator>;
118
- /**
119
- * All the available tokens.
120
- */
91
+ /** All the available tokens. */
121
92
  static readonly tokens: string[];
122
93
  private constructor();
123
- /**
124
- * String representation of this object.
125
- */
94
+ /** Makes a string key a separator type. */
95
+ static cast(key: string): Nullable<Separator>;
96
+ /** String representation of this object. */
126
97
  toString(): string;
127
98
  }
@@ -1,6 +1,6 @@
1
1
  import { NameOrder, CapsRange } from './types';
2
2
  /**
3
- * A fixed set of values to handle specific positions for list of names.
3
+ * A set of values to handle specific positions for list of names.
4
4
  *
5
5
  * As for list of names, this helps to follow a specific order based on the
6
6
  * count of elements. It is expected that the list has to be between two and
@@ -32,7 +32,7 @@ export declare class NameIndex {
32
32
  static get min(): number;
33
33
  /** The maximum number of parts in a list of names. */
34
34
  static get max(): number;
35
- private constructor();
35
+ protected constructor(prefix: number, firstName: number, middleName: number, lastName: number, suffix: number);
36
36
  /** The default or base indexing: firstName lastName. */
37
37
  static base(): NameIndex;
38
38
  /**
@@ -40,14 +40,14 @@ export declare class NameIndex {
40
40
  * and their `order` of appearance.
41
41
  */
42
42
  static when(order: NameOrder, count?: number): NameIndex;
43
+ static only({ prefix, firstName, middleName, lastName, suffix }: Record<string, number>): NameIndex;
44
+ toJson(): Record<string, number>;
45
+ json: () => Record<string, number>;
43
46
  }
44
- /**
45
- * Capitalizes a string via a `CapsRange` option.
46
- */
47
+ /** Capitalizes a string via a `CapsRange` option. */
47
48
  export declare function capitalize(str: string, range?: CapsRange): string;
48
49
  /** Decapitalizes a string via a `CapsRange` option. */
49
50
  export declare function decapitalize(str: string, range?: CapsRange): string;
50
51
  /** Toggles a string representation. */
51
52
  export declare function toggleCase(str: string): string;
52
- export declare function isStringArray(value?: unknown): boolean;
53
- export declare function isNameArray(value?: unknown): boolean;
53
+ export declare function isStringArray(value?: unknown): value is string[];
@@ -1,6 +1,6 @@
1
- import { FirstName, LastName, Name } from './name';
2
1
  import { Namon } from './types';
3
2
  import { NameIndex } from './utils';
3
+ import { FirstName, LastName, Name } from './name';
4
4
  export interface Validator<T> {
5
5
  validate(value: T): void;
6
6
  }