Wbs

This class holds a WBS (Work Breakdown Structure) value (e.g., '1.2.1'). This class ensures that such values compare correctly, for example, that '1.2' is less than '1.10' (which do not compare that way as simple text).

Properties

1
value: Stringreadonly

The WBS value

Functions

5

Appends a sub-level WBS value to this WBS code and returns a Wbs instance for it.

ParameterTypeDescription
valueString | Number
Returns: Wbs
comparestatic

Compares two WBS values, returning 0 if equal, -1 if lhs is less than rhs, or 1 if lhsis greater thanrhs`.

ParameterTypeDescription
lhsString | Wbs
rhsString | Wbs
Returns: Number
fromstatic

Returns a Wbs instance given a value. If the value is already a Wbs object, it is returned. Otherwise, a new Wbs is created. If value is null or undefined, that value is returned.

ParameterTypeDescription
valueString | Number | Wbs
Returns: Wbs

Returns truthy value if this Wbs equals the passed value.

ParameterTypeDescription
valueString | Wbs
Returns: Boolean

Compares this WBS value with a specified pattern, returning true if they match. If the pattern is simply a sequence of digits and decimal points (e.g., "1.2"), it is a match if it is a substring of this WBS code (e.g., "3.1.2.4"). If the pattern starts with * (e.g., "*.1.2"), it is a match if this WBS code ends with the text following the * (e.g., "4.3.1.2"). If the pattern ends with *, it is a match if this WBS code starts with the text up to the *.

Some examples:

 console.log(Wbs.from('1.2.3.4').match('2.3'));
 > true
 console.log(Wbs.from('1.2.3.4').match('*.4'));
 > true
 console.log(Wbs.from('1.2.3.4').match('1.2.*'));
 > true

 console.log(Wbs.from('1.2.3.4').match('2.4'));
 > false
 console.log(Wbs.from('1.2.3.4').match('*.3'));
 > false
 console.log(Wbs.from('1.2.3.4').match('2.*'));
 > false
ParameterTypeDescription
patternString

A partial WBS code (e.g., "1.2"), optionally starting or ending with *.

Returns: Boolean