Function: tryParseCompositeKey()
GalaChain core SDK 1.0.0-rc.8 / index / tryParseCompositeKey
Function: tryParseCompositeKey()
tryParseCompositeKey(
value):GalaChainTokenClassKey|undefined
Defined in: packages/gala-core-sdk/dist/index.d.ts:2237
Parses a $-joined composite key (Collection$Category$Type$AdditionalKey, what
compositeKeyOf writes) and nothing else, or undefined. It is tryParseTokenClassKey
for a string that may ONLY be in the $ form: a key that contains | is NOT read as the pipe
form here (it stays part of a segment), and only a string is accepted. The split is from the
right, so a collection that itself contains $ (production's $GMUSIC, stage's
$GMUSIC_TEST1) stays whole; 'GALA', 'GALA$Unit$none', 'ETIME$$$', 'GALA$Unit$none$' and
'$$$$' are undefined.
It replaces an app's own parseCompositeKey(key): Components | null (?? null), which had
exactly these semantics.
Parameters
value
unknown
Returns
GalaChainTokenClassKey | undefined
Example
tryParseCompositeKey('$GMUSIC_TEST1$Unit$none$none')?.collection; // '$GMUSIC_TEST1'
tryParseCompositeKey('GALA$Unit$none'); // undefined