astro.Function.parseSystemName - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / astro / parseSystemName
parseSystemName(
name):SystemNameParts|null
Defined in: src/astro/system-name.ts:155
Parse a procedural system name into its parts.
The region name may itself contain digits (Col 285 Sector), so parsing walks
the suffix backwards from the end. Returns null for anything that is not a
well-formed procedural system name.
string
A system name in any casing, with optional surrounding whitespace,
e.g. blae eock kc-c d0.
SystemNameParts | null
The parsed parts, or null if the name is malformed. A nullish name
answers null too: this parser tolerates an absent name, deliberately, so a caller
can hand it a field that may not be there. ProceduralSystem.fromName is the stricter
factory over the same grammar — it throws TypeError for anything but a string.
Surrounding whitespace is trimmed off the name before it is parsed, so it never
reaches regionName either (parseSystemName(' synuefe … ').regionName === 'synuefe').
Beyond that, parsing does not canonicalize casing: regionName is captured
verbatim from the input. The letters and mass code become numeric indices, so
re-formatting them is always canonical, but the region is not — use
canonicalizeSystemName (or build a ProceduralSystem via
ProceduralSystem.fromName) if you need the region re-cased too.
If name is present and not a string. Tolerating an absent name is
not tolerating any value at all: a number where a name belongs is a caller bug, and it
is named rather than left to fail on a method it does not have.