Skip to main content
Version: v0.0.6

Function: tokenizeRecord()

tokenizeRecord(record, d, onUnknownEscape?): AstmField[]

Tokenize a single record string (its terminator already stripped) into its fields. fields[0] is the type-letter field; ASTM data fields follow at 1-based indices.

Parameters

record

string

The raw record text.

d

Delimiters

The delimiters resolved from the header.

onUnknownEscape?

(fieldIndex) => void

Called (with the 1-based field index) for each unrecognized escape sequence encountered, so the caller can warn.

Returns

AstmField[]

The record's fields.

Example

import { tokenizeRecord, CANONICAL_DELIMITERS } from "@cosyte/astm";
const fields = tokenizeRecord("R|1|^^^687|28.6|U/L", CANONICAL_DELIMITERS);
fields[3].components[0]; // "28.6"