Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Latest commit

 

History

History
188 lines (120 loc) · 5.74 KB

File metadata and controls

188 lines (120 loc) · 5.74 KB

@nsf-open/ember-username-utils

@nsf-open/ember-username-utils

Table of contents

Type aliases

Functions

Type aliases

FormatMacroOptions

Ƭ FormatMacroOptions: FormatOptions & { fallbackKey?: string }

Configuration options for the name formatter computed decorators.

Defined in

computed-macros.ts:12


FormatOptions

Ƭ FormatOptions: Object

Configuration options for the name formatters.

Type declaration

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.

Defined in

formatters.ts:11

Functions

formatFirstNameFirst

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'

Parameters

Name Type
firstNameKey string
middleNameKey string
lastNameKey string
options FormatMacroOptions

Returns

default<string, string>

Defined in

computed-macros.ts:35


formatLastNameFirst

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'

Parameters

Name Type
firstNameKey string
middleNameKey string
lastNameKey string
options FormatMacroOptions

Returns

default<string, string>

Defined in

computed-macros.ts:72


toFirstNameFirstFormat

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

Parameters

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 -

Returns

string

The formatted name.

Defined in

formatters.ts:40


toLastNameFirstFormat

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.

Parameters

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 -

Returns

string

The formatted name.

Defined in

formatters.ts:94