Home Manual Reference Source Test Repository
public class | source

Trait

Provides a wrapper around a data field which may be an array, function or other primitive value.

Constructor Summary

Public Constructor
public

constructor(metric: string, data: *)

Initializes trait data.

Member Summary

Public Members
public get

Returns the associated metric type.

public get

type: string: *

Returns the typeof data being wrapped.

Private Members
private

_data: *

Stores the data to wrap.

private

Stores the Trait metric type.

Method Summary

Public Methods
public

valueOf(params: *): *

Returns the value of the given data.

Public Constructors

public constructor(metric: string, data: *) source

Initializes trait data.

Params:

NameTypeAttributeDescription
metric string

The name of Halstead metric being stored.

data *

Data to wrap.

Public Members

public get metric: string: * source

Returns the associated metric type.

Return:

string

public get type: string: * source

Returns the typeof data being wrapped.

Return:

string

Private Members

private _data: * source

Stores the data to wrap.

private _metric: string source

Stores the Trait metric type.

Public Methods

public valueOf(params: *): * source

Returns the value of the given data. If the wrapped data is a function it is invoked with the given params otherwise the data is returned directly. If the wrapped data is an array a mapped version is returned with each entry that is a function being invoked with the given params.

Params:

NameTypeAttributeDescription
params *

Provides parameters which are forwarded onto any data stored as a function. Normally params should be the current AST node, parent AST node, ... optional data.

Return:

*