The size of the decorated property or class.
Optional
opt: Partial<PrePostOptions>Optional configution.
The class or property decorator function.
In the following example the structure of the Block
is fixed based on
a property known at runtime.
The @EnsureSize
decorator move the cursor to always move the cursor
to the correct position after read or write.
@EnsureSize('_size')
class Block {
@NullTerminatedString()
content: string
constructor(public _size: number) {}
}
class Protocol {
@Uint16
block_size: number
@Uint32
block_count: number
@Count('block_count')
@Relation(Block, 'block_size')
blocks: Block[]
}
@EnsureSize
decorator force the decorated property to meet a size constraint. If that size is not met the cursor will be moved.