getEntity()function
getEntity(entity: Entity<T>): [type: T, id: string]
getEntity(entity: Nullish<Entity<T>>): [type: T, id: string] | EmptyEntity
getEntity(entity: Nullish<string>): [type: string, id: string] | EmptyEntity
| Param | Type | |
|---|---|---|
entity | Entity<T> | The entity string to split, or a nullish value. required |
entity | Nullish<Entity<T>> | Nullish is the value or null or undefined. required |
entity | Nullish<string> | Nullish is the value or null or undefined. required |
| Return | |
|---|---|
[type: T, id: string] | A [type, id] tuple, or EMPTY_ENTITY if the entity was missing or invalid. |
[type: T, id: string] | EmptyEntity | |
[type: string, id: string] | EmptyEntity |
Split an optional entity tag like challenge:a1b2c3 into its type and id, or return EmptyEntity if the entity was invalid.
Examples
getEntity("challenge:a1b2c3") // ["challenge", "a1b2c3"]getEntity(undefined) // [undefined, undefined]