-
Notifications
You must be signed in to change notification settings - Fork 1
/
tuef.d.ts
44 lines (44 loc) · 1.15 KB
/
tuef.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
declare module "tuef" {
export type FieldType = "A" | "N" | "AN" | "P";
export interface FixedLengthFieldSpec {
name: string;
type: FieldType;
length: number;
val?: number;
mapKey?: string;
mapFunc?: any;
required?: boolean;
defaultVal?: any;
}
export interface VaryLengthFieldSpec {
name: string;
type: FieldType;
tag: string;
length?: number;
val?: number;
mapKey?: string;
mapFunc?: any;
required?: boolean;
defaultVal?: any;
}
export type FieldSpec = VaryLengthFieldSpec | FixedLengthFieldSpec;
export type LengthType = "vary" | "fixed";
export interface SegmentSpec {
lengthType: LengthType;
fieldSpecs: Array<FieldSpec>;
}
export interface TuefSpec {
[key: string]: SegmentSpec;
}
export class Field {
constructor(spec: FieldSpec, val: any, defaultVal: any);
toString(lengthType?: LengthType): string;
}
export class Segment {
constructor(spec: SegmentSpec, data: string);
getSemicolonSeparatedHeader(): string;
toSemicolonSeparatedString(): string;
toString(): string;
}
export function parseTuef(spec: TuefSpec, str: string): object;
}