Describer
Hierarchy
- Describer
Implements
- Describer
- Describer
Index
Constructors
Methods
- createDescription
- describe
- getDescriber
- getDescribers
- hasDescriber
- overrideDescriber
- registerDescriber
- removeDescriber
- setFormatting
Object literals
Constructors
constructor
+ new Describer(describers?
: Map‹string, TypeDescriber›): Describer
Creates an instance of Describer. Creates an instance of Describer.
Parameters:
Name | Type |
---|---|
describers? | Map‹string, TypeDescriber› |
Returns: Describer
Methods
createDescription
▸ createDescription(value
: any | any[]): Stringifiable
Describes individual value or list of values(as an array).
Parameters:
Name | Type | Description |
---|---|---|
value | any | any[] | Any value or list of values. |
Returns: Stringifiable
Instance of Description for single value or DescriptionList instance as list of values.
describe
▸ describe(value
: any | any[]): string
Describes value or list of values as human readable string.
Parameters:
Name | Type | Description |
---|---|---|
value | any | any[] | Any value or list of values. |
Returns: string
String description of provided value(s).
getDescriber
▸ getDescriber(type
: string): TypeDescriber | undefined
Returns describer by mapping.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Mapping type for describer. |
Returns: TypeDescriber | undefined
Registered describer instance, else undefined.
getDescribers
▸ getDescribers(): Map‹string, TypeDescriber›
Returns all registered describers.
Returns: Map‹string, TypeDescriber›
Registered describers mappings.
hasDescriber
▸ hasDescriber(type
: string): boolean
Evaluates if describer is already registered by mapping id.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Mapping type for describer. |
Returns: boolean
Returns true if describer is registered, else false.
overrideDescriber
▸ overrideDescriber(type
: string, describer
: TypeDescriber): void
Overrides already existing describer by mapping on describer.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Type for which mapping will be created or overridden. |
describer | TypeDescriber | Describer for registration. |
Returns: void
registerDescriber
▸ registerDescriber(type
: string, describer
: TypeDescriber, shouldOverride?
: boolean): void
Registers describer on describer.
throws
{TypeDescriberExistsError}
Thrown if mapping would overridden on describer without explicit call.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Type for which mapping will be created. |
describer | TypeDescriber | Describer for registration. |
shouldOverride? | boolean | Flag indicating that mapping should be overridden if exist. |
Returns: void
removeDescriber
▸ removeDescriber(type
: string): void
Removes describer by mapping id.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Mapping type for describer. |
Returns: void
setFormatting
▸ setFormatting(formatting
: DescriberFormatting): void
Implementation of Describer
Describer initializer.
Parameters:
Name | Type | Description |
---|---|---|
formatting | DescriberFormatting | Formatting for describer as one of values: compact , debug , default . |
Returns: void
Object literals
Static
describers
▪ describers: object
[KINDS.ARRAY]
• [KINDS.ARRAY]: ArrayDescriber = ArrayDescriber
[KINDS.CLASS]
• [KINDS.CLASS]: ClassDescriber = ClassDescriber
[KINDS.DESCRIPTION_LIST]
• [KINDS.DESCRIPTION_LIST]: DescriptionListDescriber = DescriptionListDescriber
[KINDS.ERROR]
• [KINDS.ERROR]: ErrorDescriber = ErrorDescriber
[KINDS.NATIVE]
• [KINDS.NATIVE]: NativeTypeDescriber = NativeTypeDescriber
[KINDS.OBJECT]
• [KINDS.OBJECT]: ObjectDescriber = ObjectDescriber
[KINDS.UNKNOWN]
• [KINDS.UNKNOWN]: FallbackDescriber = FallbackDescriber