refine

function refine
codec.ts:71
refine<T, U>(inner: Decoder<T>, predicate: (value: T) → value is U, expected: string) → Decoder<U>

Narrow a decoded value with a runtime predicate.

This is what a branded or literal type needs, and its absence is why four decoders in this package ended in as Decoder<T>: decodeString proves the value is a string, the predicate proves it is that string, and the two together produce the narrow type honestly. A cast in that position asserts precisely the half a validator exists not to assert — decodeSaveMutation accepted any string as its kind and told the compiler it was one of four.

innerDecoder<T>
Undocumented
predicate(value: T) → value is U
Undocumented
expectedstring
Undocumented
ReturnsDecoder<U>