Constructor
new RightCharColumn()
- Source:
Example
const col = new RightCharColumn('code', 5, 'Product Code');
col.toValue(' A12'); // 'A12'
col.toStr('A12'); // ' A12'
Extends
Members
description :string
Description of the column.
Type:
- string
- Inherited From:
- Source:
end :number
1-indexed end position of the column within a row line.
Type:
- number
- Inherited From:
- Source:
name :string
Name of the column.
Type:
- string
- Inherited From:
- Source:
size :number
Character width of the column.
Type:
- number
- Inherited From:
- Source:
start :number|null
1-indexed start position of the column within a row line.
Type:
- number | null
- Inherited From:
- Source:
Methods
toStr(value) → {string}
Serializes value into a right-aligned, space-padded fixed-width string.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | null | String value to serialize. Null/undefined serializes to spaces. |
- Overrides:
- Source:
Throws:
-
If value is not a string or exceeds column size.
- Type
- Error
Returns:
Space-padded fixed-width string.
- Type
- string
toValue(slice) → {string}
Converts raw string slice from file to column value (trimmed string).
Parameters:
| Name | Type | Description |
|---|---|---|
slice |
string | Raw fixed-width slice. |
- Overrides:
- Source:
Returns:
Trimmed string value.
- Type
- string
validateToStrSize(value) → {string}
Validates that a formatted string representation matches the required column size.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | The formatted string to validate. |
- Inherited From:
- Source:
Throws:
-
If formatted string length does not equal column size.
- Type
- Error
Returns:
The validated string.
- Type
- string