Class: Util
Contains various general-purpose utility methods.
Hierarchy
any↳
Util
Constructors
constructor
• new Util()
Inherited from
null.constructor
Methods
formatTag
▸ Static formatTag(tag): string
Corrects malformed tags to match how they are formatted.
Util.formatTag("PccVqqGO"); // #PCCVQQG0
Parameters
| Name | Type |
|---|---|
tag | string |
Returns
string
Defined in
encodeURI
▸ Static encodeURI(tag): string
Encodes a tag as a valid component of a URI.
Parameters
| Name | Type |
|---|---|
tag | string |
Returns
string
Defined in
isValidTag
▸ Static isValidTag(tag): boolean
Verify a tag using RegExp. (/^#?[0289PYLQGRJCUV]$/)
Parameters
| Name | Type |
|---|---|
tag | string |
Returns
boolean
Defined in
encodeTag
▸ Static encodeTag(tag): string
Encode tag string into 64bit unsigned integer string.
Util.encodeTag('#PCCVQQG0'); // '510915076'
Parameters
| Name | Type |
|---|---|
tag | string |
Returns
string
Defined in
decodeTag
▸ Static decodeTag(id): string
Decode 64bit unsigned integer string into tag string with hash.
Util.decodeTag('510915076'); // '#PCCVQQG0'
Parameters
| Name | Type |
|---|---|
id | string |
Returns
string
Defined in
formatDate
▸ Static formatDate(date): Date
Converts API Date to JavaScript Date.
Parameters
| Name | Type |
|---|---|
date | string |
Returns
Date
Defined in
queryString
▸ Static queryString(options?): string
Returns a string containing a query string suitable for use in a URL.
Parameters
| Name | Type |
|---|---|
options | SearchOptions | ClanSearchOptions |
Returns
string
Defined in
getSeasonStart
▸ Static getSeasonStart(inputDate): Date
Parameters
| Name | Type |
|---|---|
inputDate | Date |
Returns
Date
Defined in
getSeasonEnd
▸ Static getSeasonEnd(inputDate, forward?): Date
Parameters
| Name | Type | Default value |
|---|---|---|
inputDate | Date | undefined |
forward | boolean | true |
Returns
Date
Defined in
getSeasonId
▸ Static getSeasonId(): string
Get the current season ID.
Returns
string
Defined in
getSeason
▸ Static getSeason(timestamp?, forward?): Object
Get the season start and end timestamp.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
timestamp? | Date | undefined | The reference date. Defaults to the current date if not provided. |
forward | boolean | true | Whether to forward to the next month if the returned date is in the past relative to the given timestamp. Defaults to true. |
Returns
Object
| Name | Type |
|---|---|
endTime | Date |
startTime | Date |
Defined in
allSettled
▸ Static allSettled<T>(values): Promise<T[]>
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
values | Promise<T>[] |
Returns
Promise<T[]>
Defined in
delay
▸ Static delay(ms): Promise<unknown>
Parameters
| Name | Type |
|---|---|
ms | number |
Returns
Promise<unknown>
Defined in
parseArmyLink
▸ Static parseArmyLink(link): Object
Parse in-game army link into troops and spells count with respective Id's.
Parameters
| Name | Type |
|---|---|
link | string |
Returns
Object
| Name | Type |
|---|---|
units | { name: null | string ; count: number = unit.total; id: number = unit.id }[] |
spells | { name: null | string ; count: number = spell.total; id: number = spell.id }[] |