Constructor
new CharColumn()
- Source:
Example
const col = new CharColumn('name', 20, 'User Name');
col.toValue('KELSON MEDEIROS '); // 'KELSON MEDEIROS'
col.toStr('KELSON MEDEIROS'); // 'KELSON MEDEIROS '
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 left-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