(s: string)
| 146 | * @since 4.0.0 |
| 147 | */ |
| 148 | export function fromStringEncoded(s: string): { |
| 149 | readonly group: string |
| 150 | readonly id: number |
| 151 | } { |
| 152 | const index = s.lastIndexOf(":") |
| 153 | if (index === -1) { |
| 154 | throw new Error(`Invalid ShardId format`) |
| 155 | } |
| 156 | const group = s.substring(0, index) |
| 157 | const id = Number(s.substring(index + 1)) |
| 158 | if (isNaN(id)) { |
| 159 | throw new Error(`ShardId id must be a number`) |
| 160 | } |
| 161 | return { group, id } |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Parses a `group:id` string into a cached `ShardId`. |