How to use the prelude-ts.HashMap.ofIterable function in prelude-ts

To help you get started, we’ve selected a few prelude-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klemola / foobar2000-web-ui / server / Message.ts View on Github external
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)
}

prelude-ts

A typescript functional programming library

ISC
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis