## Classes
Name

A class to parse names of people. Different locales have different conventions when it comes to naming people.

NameFmt

Represents a formatter that can format person name instances (Name) for display to a user.

Formatting names is a locale-dependent function, as the order of the components depends on the locale. The following explains some of the details:

## Name A class to parse names of people. Different locales have different conventions when it comes to naming people.

**Kind**: global class * [Name](#Name) * [new Name(name, [options])](#new_Name_new) * _instance_ * [.prefix](#Name+prefix) : string \| Array.<string> * [.givenName](#Name+givenName) : string \| Array.<string> * [.middleName](#Name+middleName) : string \| Array.<string> * [.familyName](#Name+familyName) : string \| Array.<string> * [.suffix](#Name+suffix) : string \| Array.<string> * [.honorific](#Name+honorific) : string \| Array.<string> * [.getSortFamilyName()](#Name+getSortFamilyName) ⇒ string \| undefined * [.clone()](#Name+clone) * _static_ * [.create(name, options)](#Name.create) ⇒ Promise * * * ### new Name(name, [options]) Create a new instance of a Name. This parses the name and puts the result in the various fields.

The options can contain any of the following properties:

Additionally, a name instance can be constructed by giving the explicit already-parsed fields or by using another name instance as the parameter. (That is, it becomes a copy constructor.) The name fields can be any of the following: When the parser has completed its parsing, it fills in the same fields as listed above.

For names that include auxilliary words, such as the family name "van der Heijden", all of the auxilliary words ("van der") will be included in the field.

For names in some Spanish locales, it is assumed that the family name is doubled. That is, a person may have a paternal family name followed by a maternal family name. All family names will be listed in the familyName field as normal, separated by spaces. When formatting the short version of such names, only the paternal family name is used. | Param | Type | Description | | --- | --- | --- | | name | string \| [Name](#Name) \| Object | the name to parse | | [options] | Object | Options governing the construction of this name instance | * * * ### name.prefix : string \| Array.<string> The prefixes for this name **Kind**: instance property of [Name](#Name) * * * ### name.givenName : string \| Array.<string> The given (personal) name in this name. **Kind**: instance property of [Name](#Name) * * * ### name.middleName : string \| Array.<string> The middle names used in this name. If there are multiple middle names, they all appear in this field separated by spaces. **Kind**: instance property of [Name](#Name) * * * ### name.familyName : string \| Array.<string> The family names in this name. If there are multiple family names, they all appear in this field separated by spaces. **Kind**: instance property of [Name](#Name) * * * ### name.suffix : string \| Array.<string> The suffixes for this name. If there are multiple suffixes, they all appear in this field separated by spaces. **Kind**: instance property of [Name](#Name) * * * ### name.honorific : string \| Array.<string> The honorific title for this name. This honorific will be used as the prefix or suffix as dictated by the locale **Kind**: instance property of [Name](#Name) * * * ### name.getSortFamilyName() ⇒ string \| undefined When sorting names with auxiliary words (like "van der" or "de los"), determine which is the "head word" and return a string that can be easily sorted by head word. In English, names are always sorted by initial characters. In places like the Netherlands or Germany, family names are sorted by the head word of a list of names rather than the first element of that name. **Kind**: instance method of [Name](#Name) **Returns**: string \| undefined - a string containing the family name[s] to be used for sorting in the current locale, or undefined if there is no family name in this object * * * ### name.clone() Return a shallow copy of the current instance. **Kind**: instance method of [Name](#Name) **Access**: protected * * * ### Name.create(name, options) ⇒ Promise Factory method to create a new instance of Name asynchronously. The parameters are the same as for the constructor, but it returns a `Promise` instead of the instance directly. **Kind**: static method of [Name](#Name) **Returns**: Promise - a promise to load a Name instance. The resolved value of the promise is the new instance of Name, | Param | Type | Description | | --- | --- | --- | | name | string | the name to parse | | options | Object | the same objects you would send to a constructor | * * * ## NameFmt Represents a formatter that can format person name instances (Name) for display to a user.

Formatting names is a locale-dependent function, as the order of the components depends on the locale. The following explains some of the details:

**Kind**: global class * [NameFmt](#NameFmt) * [new NameFmt(options)](#new_NameFmt_new) * _instance_ * [.getLocale()](#NameFmt+getLocale) ⇒ Locale * [.getStyle()](#NameFmt+getStyle) ⇒ string * [.getComponents()](#NameFmt+getComponents) ⇒ string * [.format(name)](#NameFmt+format) ⇒ string \| undefined * _static_ * [.create(options)](#NameFmt.create) ⇒ Promise * * * ### new NameFmt(options) Create an instance of a name formatter.

The options may contain the following properties:

For example, the string "pf" would mean to only format any prefixes and family names together and leave out all the other parts of the name.

The components can be listed in any order in the string. The components option overrides the style option if both are specified. | Param | Type | Description | | --- | --- | --- | | options | Object | A set of options that govern how the formatter will behave | * * * ### nameFmt.getLocale() ⇒ Locale Return the locale for this formatter instance. **Kind**: instance method of [NameFmt](#NameFmt) **Returns**: Locale - the locale instance for this formatter * * * ### nameFmt.getStyle() ⇒ string Return the style of names returned by this formatter **Kind**: instance method of [NameFmt](#NameFmt) **Returns**: string - the style of names returned by this formatter * * * ### nameFmt.getComponents() ⇒ string Return the list of components used to format names in this formatter **Kind**: instance method of [NameFmt](#NameFmt) **Returns**: string - the list of components * * * ### nameFmt.format(name) ⇒ string \| undefined Format the name for display in the current locale with the options set up in the constructor of this formatter instance.

If the name does not contain all the parts required for the style, those parts will be left blank.

There are two basic styles of formatting: European, and Asian. If this formatter object is set for European style, but an Asian name is passed to the format method, then this method will format the Asian name with a generic Asian template. Similarly, if the formatter is set for an Asian style, and a European name is passed to the format method, the formatter will use a generic European template.

This means it is always safe to format any name with a formatter for any locale. You should always get something at least reasonable as output.

**Kind**: instance method of [NameFmt](#NameFmt) **Returns**: string \| undefined - the name formatted according to the style of this formatter instance | Param | Type | Description | | --- | --- | --- | | name | [Name](#Name) \| Object | the name instance to format, or an object containing name parts to format | * * * ### NameFmt.create(options) ⇒ Promise Factory method to create a new instance of NameFmt asynchronously. The parameters are the same as for the constructor, but it returns a `Promise` instead of the instance directly. **Kind**: static method of [NameFmt](#NameFmt) **Returns**: Promise - a promise to load a NameFmt instance. The resolved value of the promise is the new instance of NameFmt, | Param | Type | Description | | --- | --- | --- | | options | Object | the same objects you would send to a constructor | * * *