The relation type that contains the nested property.
The property inside the relation that should be extracted when reading and re-encapsulated when writing.
Optional
args: RelationParameters<This, Args>The property decorator function.
In the following example @Flatten
is used to create array of string while
also applying operation to that inner in string in the ProtocolString
definition.
The ProtocolString
parse null terminated strings but ensure the size of
a string block is always of 64 bytes.
class ProtocolString {
@EnsureSize(64)
@NullTerminatedString()
data: string
}
class Protocol {
@Until(EOF)
@Flatten(ProtocolString, 'data')
strings: string[]
}
@Flatten
decorator defines a relation and extract a single property from the nested relation. The decorator 'flatten' the structure during the reading phase and reconstruct it during the writing phase.