Resources
namefully provides some ready-made recipes with some extra functionalities. They
work independently. That is to say, you don't need an instance of namefully to
work with a specific name part like a first name, for example.
They are 3 basic classes:
NameFirstnameLastname
note
Some of the APIs that are available in Namefully are also available in these
classes. But these classes contain certain functionalities that are native.
Name
This class represents a namon (i.e., a piece of name in a string format) with
some extra capabilities, compared to a simple string utils provided by JavaScript.
This class helps to define the role of a name part (e.g., prefix) before anything.
Example:
As you can see, the 5 types of name can be created from that class. Additionally, you can specify which kind of capitalizations to use when manipulating that piece of name.
API:
| Methods | Arguments | Default | Returns | Description |
|---|---|---|---|---|
| getInitials | none | none | string[] | Gets the initials of the name |
| describe | none | none | Summary | Gives some descriptive statistics of the characters' distribution |
| upper | none | none | string | Returns a lowercase string representation of the namon |
| lower | none | none | string | Returns a lowercase string representation of the namon |
Aliases:
None
Firstname
This class is an extended arm of Name and represents a given name. It can work
with more than one name part.
Example:
An instance of this class handles separately the required namon along with the optional other given names a person might have.
API:
| Methods | Arguments | Default | Returns | Description |
|---|---|---|---|---|
| tostring | includeAll | false | string | Returns a string representation of the first name |
| getInitials | includeAll | false | string[] | Gets the initials of the first name |
| describe | includeAll | false | Summary | Gives some descriptive statistics of the characters' distribution |
Aliases:
None
Lastname
This class is an extended arm of Name and represents a surname. It handles
two types of surname: a father's and a mother's.
Pay attention to the third argument (optional): format. It defines how the surname per se should be output. By default, the father's name is considered.
Example:
API:
| Methods | Arguments | Default | Returns | Description |
|---|---|---|---|---|
| tostring | format | null | string | Returns a string representation of the last name |
| getInitials | format | null | string[] | Gets the initials of the last name |
| describe | format | null | Summary | Gives some descriptive statistics of the characters' distribution |
Aliases:
None
Not sure to know how to use these classes? See some examples.
Summary
Another class, which does not seem to be very useful but is provided anyway, is:
Summary. It represents the statistical summary of a string representation or a
namon. The derived categorical statistics is:
- count: number of characters in the namon
- top: which character appears more frequently
- frequency: how many times this frequent character appears
- unique: how many unique characters
This is actually what the describe() method is doing.
Example: