Class: RowDescriptor

RowDescriptor(columns)

Descriptor representing a single row layout structure in a Fixed Width File. Calculates column start/end offsets automatically and extracts typed object records from raw line strings.

Constructor

new RowDescriptor(columns)

Creates an instance of RowDescriptor.
Parameters:
Name Type Description
columns Array.<AbstractColumn> List of column instances composing the row layout.
Source:
Throws:
  • If columns argument is not an Array or elements are not AbstractColumn instances.
    Type
    TypeError
  • If columns array is empty or column positions overlap/contain gaps.
    Type
    Error
Example
const descriptor = new RowDescriptor([
  new CharColumn('name', 20),
  new PositiveIntegerColumn('age', 3)
]);
console.log(descriptor.lineSize); // 23
const row = descriptor.getValues('KELSON MEDEIROS     045');
// { name: 'KELSON MEDEIROS', age: 45 }

Classes

RowDescriptor

Members

columns :Array.<AbstractColumn>

List of columns forming this row descriptor.
Type:
Source:

lineSize :number

Total line size width in characters calculated from the last column's end position.
Type:
  • number
Source:

Methods

getValues(rowLine) → {Record.<string, *>}

Extracts and parses a raw fixed-width row line string into a key-value object of typed values.
Parameters:
Name Type Description
rowLine string Fixed-width row string matching the line size.
Source:
Throws:
If rowLine is not a string.
Type
TypeError
Returns:
Object containing parsed column key-value pairs.
Type
Record.<string, *>

validatePositions()

Validates contiguous column alignment starting from position 1 without gaps or overlaps.
Source:
Throws:
If alignment check fails.
Type
Error