Class: AbstractColumn

(abstract) AbstractColumn(name, size, descriptionopt)

Base abstract class for all fixed-width file columns. Defines common properties (name, size, description, start/end position) and validation methods.

Constructor

(abstract) new AbstractColumn(name, size, descriptionopt)

Creates an instance of AbstractColumn.
Parameters:
Name Type Attributes Default Description
name string Unique identifier/name of the column.
size number Positional size (character width) of the column, must be > 0.
description string | null <optional>
null Description of the column. Defaults to name if omitted.
Source:
Throws:
  • If name is not a string.
    Type
    TypeError
  • If name is blank or size is not an integer > 0.
    Type
    Error

Classes

AbstractColumn

Members

description :string

Description of the column.
Type:
  • string
Source:

end :number

1-indexed end position of the column within a row line.
Type:
  • number
Source:

name :string

Name of the column.
Type:
  • string
Source:

size :number

Character width of the column.
Type:
  • number
Source:

start :number|null

1-indexed start position of the column within a row line.
Type:
  • number | null
Source:

Methods

(abstract) toStr(value) → {string}

Serializes a JavaScript typed value into a fixed-width string representation.
Parameters:
Name Type Description
value * Value to serialize.
Source:
Throws:
If not implemented by concrete column subclass.
Type
Error
Returns:
Fixed-width formatted string.
Type
string

toValue(slice) → {*}

Converts a raw string slice extracted from a fixed-width row line into a typed value.
Parameters:
Name Type Description
slice string The exact substring matching the column size.
Source:
Throws:
If slice is not a string or slice length does not match column size.
Type
Error
Returns:
The parsed value.
Type
*

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.
Source:
Throws:
If formatted string length does not equal column size.
Type
Error
Returns:
The validated string.
Type
string