Home Manual Reference Source Test Repository
public class | source

TraitHalstead

Provides a wrapper around a data object hash which should contain an identifier field and potentially a filter field which is a function. The identifier can be a function or string or an array of functions / strings.

Constructor Summary

Public Constructor
public

constructor(metric: string, data: object)

Initializes the Halstead trait.

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 Halstead metric type.

Method Summary

Public Methods
public

filter(params: *): boolean

Returns the value of the filter field of the wrapped data.

public

valueOf(params: *): * | Array<*>

Returns the value of the identifier field of the wrapped data.

Public Constructors

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

Initializes the Halstead trait.

Params:

NameTypeAttributeDescription
metric string

The name of Halstead metric being stored.

data object

The data field to be wrapped.

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 Halstead metric type.

Public Methods

public filter(params: *): boolean source

Returns the value of the filter field of the wrapped data. If the wrapped filter field is a function it is invoked with the given params otherwise the data is returned directly. If filter is not defined then true is returned.

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:

boolean

public valueOf(params: *): * | Array<*> source

Returns the value of the identifier field of the wrapped data. If the wrapped identifier field is a function it is invoked with the given params otherwise the data is returned directly.

Params:

NameTypeAttributeDescription
params *

Provides parameters which are forwarded onto any data stored as a function.

Return:

* | Array<*>