Skip to main content
Version: v0.0.2

Function: sliceField()

sliceField(line, slice): string

Extract and trim a FieldSlice from a line (end omitted slices to end of line).

Parameters

line

string

The source line.

slice

FieldSlice

The half-open [start, end) slice.

Returns

string

The trimmed field text (empty when the slice is entirely past the line's end).

Example

import { sliceField } from "@cosyte/terminology";

sliceField("00001 A00 1 Cholera", { start: 6, end: 13 }); // => "A00"