Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseTrackData(text: string): Result {
const items = Vector.ofIterable(text.split('|'))
const status = items.head()
// Get rid of fields that we don't care about
const otherValues = items.drop(3)
if (status.isNone() || otherValues.length() < trackInfoKeys.length - 1) {
return failure('Could not parse track data')
}
const values = otherValues.prepend(status.get())
const trackInfoEntries = Vector.zip(trackInfoKeys, values)
const trackInfo = HashMap.ofIterable(trackInfoEntries)
.filterKeys(k => !k.startsWith('unknown'))
.map((k, v) => [k, mapTrackInfoValue(k, v)])
.put('state', statusCodeToName(status.get()))
.toObjectDictionary(x => x)
return TrackInfo.validate(trackInfo)
}