@nsf-open/ember-username-utils
Ƭ FormatMacroOptions: FormatOptions
& { fallbackKey?
: string
}
Configuration options for the name formatter computed decorators.
Ƭ FormatOptions: Object
Configuration options for the name formatters.
Name | Type | Description |
---|---|---|
defaultText? |
string |
Alternative text to return if no other value could be built. |
noMiddleInitial? |
boolean |
If true, the middle initial will be completely excluded from the built string. |
noMiddleInitialPunctuation? |
boolean |
If true, the middle initial will not be punctuated with a trailing period. |
▸ formatFirstNameFirst(firstNameKey
, middleNameKey
, lastNameKey
, options?
): default
<string
, string
>
Exposes the toFirstNameFirstFormat
formatter as an Ember computed decorator to format a
person's name starting with their first name, depending on what is provided.
public firstName = 'John';
public middleName = 'Hubert';
public surname = 'Doe';
@formatFirstNameFirst('firstName', 'middleName', 'surname')
public fullName!: string; // => 'John H. Doe'
Name | Type |
---|---|
firstNameKey |
string |
middleNameKey |
string |
lastNameKey |
string |
options |
FormatMacroOptions |
default
<string
, string
>
▸ formatLastNameFirst(firstNameKey
, middleNameKey
, lastNameKey
, options?
): default
<string
, string
>
Exposes the toLastNameFirstFormat
formatter as an Ember computed decorator to format a
person's name starting with their last name, depending on what is provided.
public firstName = 'John';
public middleName = 'Hubert';
public surname = 'Doe';
@formatLastNameFirst('firstName', 'middleName', 'surname')
public fullName!: string; // => 'Doe, H. John'
Name | Type |
---|---|
firstNameKey |
string |
middleNameKey |
string |
lastNameKey |
string |
options |
FormatMacroOptions |
default
<string
, string
>
▸ toFirstNameFirstFormat(firstName?
, middleName?
, lastName?
, options?
): string
Formats a person's name starting with their first name, depending on what is provided.
toFirstNameFirstFormat('John', 'Quincy', 'Doe'); // John Q. Doe
toFirstNameFirstFormat('John', undefined, 'Doe'); // John Doe
toFirstNameFirstFormat('John', 'Quincy'); // John Q.
toFirstNameFirstFormat(undefined, 'Quincy', 'Doe'); // Q. Doe
Name | Type | Description |
---|---|---|
firstName? |
MaybeString |
The person's first name. |
middleName? |
MaybeString |
The person's middle name. |
lastName? |
MaybeString |
The person's last name. |
options |
FormatOptions |
- |
string
The formatted name.
▸ toLastNameFirstFormat(firstName?
, middleName?
, lastName?
, options?
): string
Formats a person's name starting with their last name, depending on what is provided.
toLastNameFirstFormat('John', 'Quincy', 'Doe'); // Doe, John, Q.
toLastNameFirstFormat('John', undefined, 'Doe'); // Doe, John
toLastNameFirstFormat('John', 'Quincy'); // John Q.
toLastNameFirstFormat(undefined, 'Quincy', 'Doe'); // Doe, Q.
Name | Type | Description |
---|---|---|
firstName? |
MaybeString |
The person's first name. |
middleName? |
MaybeString |
The person's middle name. |
lastName? |
MaybeString |
The person's last name. |
options |
FormatOptions |
- |
string
The formatted name.