Function that will store the return value in the decorated property.
Optional
opt: Partial<PrePostOptions>Optional configution.
The class or property decorator function.
In the following example @ValueSet
is used to fetch the protocol type name
based on an id read in by the binary definition.
The protocol_name
will just appear when the object is serialized and will
gave the object more context.
const ID_TO_NAME = {
1: "Record",
...
}
class Protocol {
@Relation(PrimitiveSymbol.u8)
protocol_id: number
@ValueSet(_ => ID_TO_NAME[_.protocol_id] || 'UNKNOWN')
protocol_name: string
}
@ValueSet
decorator set the value of the decorated property based on a function passed as a parameter. This decorator don't read anything from the binary file and is just used to add more context to a class during the reading.