Skip to content
This repository was archived by the owner on Jul 20, 2021. It is now read-only.

Commit 2eaa150

Browse files
author
Per Kristian Kummermo
committed
feat(mappers): type constructors. Fixes #2
1 parent 544cc87 commit 2eaa150

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/mappers/Base64.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export enum Base64Actions {
55
DECODE = "decode",
66
}
77

8+
export interface IBase64Config {
9+
action?: Base64Actions;
10+
}
11+
812
export class Base64 implements IMapper {
913
static ident: string = "BASE64";
1014
static description: string = "Base64";
@@ -14,7 +18,7 @@ export class Base64 implements IMapper {
1418

1519
constructor({
1620
action = Base64Actions.DECODE,
17-
} = {}) {
21+
}: IBase64Config = {}) {
1822
this.action = action;
1923
}
2024

src/mappers/FromJSON.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { IDataValue, IMapper, IMapperConfig } from "./../Models";
22

3+
export interface IFromJSONConfig {
4+
propertyString?: string;
5+
}
6+
37
export class FromJSON implements IMapper {
48
static ident: string = "FROMJSON";
59
static description: string = "JSON";
@@ -9,7 +13,7 @@ export class FromJSON implements IMapper {
913

1014
constructor({
1115
propertyString = "",
12-
} = {}) {
16+
}: IFromJSONConfig = {}) {
1317
this.propertyString = propertyString;
1418
}
1519

src/mappers/HexToFloat.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
21
import { Endianness } from "../Config";
32
import { IDataValue, IMapper, IMapperConfig } from "./../Models";
43

4+
export interface IHexToFloatConfig {
5+
endianness?: Endianness;
6+
}
7+
58
export class HexToFloat implements IMapper {
69
static ident: string = "HEXTOFLOAT";
710
static description: string = "Hex to float";
@@ -11,7 +14,7 @@ export class HexToFloat implements IMapper {
1114

1215
constructor({
1316
endianness = Endianness.BIG_ENDIAN,
14-
} = {}) {
17+
}: IHexToFloatConfig = {}) {
1518
this.endianness = endianness;
1619
}
1720

src/mappers/HexToInt.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Endianness } from "../Config";
22
import { IDataValue, IMapper, IMapperConfig } from "./../Models";
33

4+
export interface IHexToIntConfig {
5+
endianness?: Endianness;
6+
signed?: boolean;
7+
}
8+
49
export class HexToInt implements IMapper {
510
static ident: string = "HEXTOINT";
611
static description: string = "Hex to int";
@@ -13,7 +18,7 @@ export class HexToInt implements IMapper {
1318
constructor({
1419
endianness = Endianness.BIG_ENDIAN,
1520
signed = false,
16-
} = {}) {
21+
}: IHexToIntConfig = {}) {
1722
this.endianness = endianness;
1823
this.signed = signed;
1924
}

src/mappers/Offset.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { IDataValue, IMapper, IMapperConfig } from "./../Models";
22

3+
export interface IOffsetConfig {
4+
offset?: number | string;
5+
}
6+
37
export class Offset implements IMapper {
48
static ident: string = "OFFSET";
59
static description: string = "Offset number";
@@ -8,7 +12,7 @@ export class Offset implements IMapper {
812

913
constructor({
1014
offset = "0",
11-
} = {}) {
15+
}: IOffsetConfig = {}) {
1216
this.offset = parseInt(offset.toString(), 10);
1317
}
1418

0 commit comments

Comments
 (0)