Skip to content

Merging kinks: Another serialization rabbit-hole #31

Description

@pixelcmtd

While trying to merge two kinks for KCC v0.9, I noticed that the current serialization format doesn't allow us to carry over ratings in that case. Merging two kinks ["A", [""]] and ["B", [""]] into a new kink ["C", ["a", "b"]] can only reasonably get a new ID, which throws away existing ratings. But this is a case where the serialization format could help, and therefore imo it should. This might, however, be quite difficult to implement.

Alternative 1: Flat format (checkData = { ratings: optional<validRating>[] })

We could overhaul the entire serialization format to just store a list of ratings:

type kink = [string, [""], [number]]
          | [string, [""], [number], string]
          | [string, [string, string], [number, number]]
          | [string, [string, string], [number, number], string]

type checkData = { ratings: (validRating | undefined | null)[] }

// decodeKinkCheck:
kid.map(i => s.ratings[i]) // .filter(r => r || r === 0)

Alternative 2: Special cases (kink.id = number | [number, number])

Alternatively, we can keep most of the serialization as-is, and patch up that specific case:

type kink = [string, positions, number | number[]]
          | [string, positions, number | number[], string]

type checkData = { ratings: (validRating[] | undefined | null)[] }

// decodeKinkCheck:
typeof kid === "number" ? s.ratings[kid] : kid.flatMap(i => s.ratings[i])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions