attributes
Implements typechecking instance attributes.
Functions
Section titled “Functions”Attribute
Section titled “Attribute”function attributes.Attribute( name: string, check: t.check<T>, default: T?): Attribute<T>
Creates a new Attribute
object with the name, an optional typecheckr, and
an optional default value.
Parameters
Section titled “Parameters”name : string
Section titled “name : string”The name of the attribute.
check : t.check<T>
Section titled “check : t.check<T>”An optional t.check
function to validate the type of the attribute’s value.
default : T?
Section titled “default : T?”An optional default value for the attribute if it’s not set or invalid.
Returns
Section titled “Returns”Attribute<T>
Section titled “Attribute<T>”A new Attribute
object.`
AttributeGroup
Section titled “AttributeGroup”function attributes.AttributeGroup( prefix: string, check: t.check<T>, pattern: string?): AttributeGroup<T>
Creates a new AttributeGroup
object with the name, an optional typechecker,
and an optional pattern.
Parameters
Section titled “Parameters”prefix : string
Section titled “prefix : string”The common prefix for all attributes in this group (e.g., “Property”, “Dismounts”).
check : t.check<T>
Section titled “check : t.check<T>”An optional t.check
function to validate the type of each attribute’s value within this group.
pattern : string?
Section titled “pattern : string?”An optional string pattern to extract a unique key from the attribute name. Defaults to ^{prefix}_(%w+)
, which captures word characters after the prefix and an underscore.
Returns
Section titled “Returns”AttributeGroup<T>
Section titled “AttributeGroup<T>”A new AttributeGroup
object.`