specificity()
import { specificity } from "@fed1/jsos";
A JSFunction
that calculates a TType's specificity: a number
repesenting how far removed it is from the hierarchy root TAny.
If a type has more than one parent, the longest route to TAny
is used as its
specificity.
Since the type hierarchy cannot be changed, only appended to, the specificty is constant after a type's creation and therefore only calculated once and then cached.
Usage
specificity(typeObject)
Parameters
# | Parameter | Required? | Type | Default |
---|---|---|---|---|
1 | typeObject | yes | TType |
1. typeObject
The type whose specificity shall be calculated.
Return value
A JSNumber
that represents the type's specificity as a whole number. It's 1
for TAny
and greater than 1
for every other type.
Version History
Feature | Since version |
---|---|
specificity() | 1.0 |
See also
- API: TType
- Manual: The Type Graph