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

Commit

Permalink
feat(mappers): type constructors. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Kristian Kummermo committed May 8, 2018
1 parent 544cc87 commit 2eaa150
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/mappers/Base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export enum Base64Actions {
DECODE = "decode",
}

export interface IBase64Config {
action?: Base64Actions;
}

export class Base64 implements IMapper {
static ident: string = "BASE64";
static description: string = "Base64";
Expand All @@ -14,7 +18,7 @@ export class Base64 implements IMapper {

constructor({
action = Base64Actions.DECODE,
} = {}) {
}: IBase64Config = {}) {
this.action = action;
}

Expand Down
6 changes: 5 additions & 1 deletion src/mappers/FromJSON.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { IDataValue, IMapper, IMapperConfig } from "./../Models";

export interface IFromJSONConfig {
propertyString?: string;
}

export class FromJSON implements IMapper {
static ident: string = "FROMJSON";
static description: string = "JSON";
Expand All @@ -9,7 +13,7 @@ export class FromJSON implements IMapper {

constructor({
propertyString = "",
} = {}) {
}: IFromJSONConfig = {}) {
this.propertyString = propertyString;
}

Expand Down
7 changes: 5 additions & 2 deletions src/mappers/HexToFloat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

import { Endianness } from "../Config";
import { IDataValue, IMapper, IMapperConfig } from "./../Models";

export interface IHexToFloatConfig {
endianness?: Endianness;
}

export class HexToFloat implements IMapper {
static ident: string = "HEXTOFLOAT";
static description: string = "Hex to float";
Expand All @@ -11,7 +14,7 @@ export class HexToFloat implements IMapper {

constructor({
endianness = Endianness.BIG_ENDIAN,
} = {}) {
}: IHexToFloatConfig = {}) {
this.endianness = endianness;
}

Expand Down
7 changes: 6 additions & 1 deletion src/mappers/HexToInt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Endianness } from "../Config";
import { IDataValue, IMapper, IMapperConfig } from "./../Models";

export interface IHexToIntConfig {
endianness?: Endianness;
signed?: boolean;
}

export class HexToInt implements IMapper {
static ident: string = "HEXTOINT";
static description: string = "Hex to int";
Expand All @@ -13,7 +18,7 @@ export class HexToInt implements IMapper {
constructor({
endianness = Endianness.BIG_ENDIAN,
signed = false,
} = {}) {
}: IHexToIntConfig = {}) {
this.endianness = endianness;
this.signed = signed;
}
Expand Down
6 changes: 5 additions & 1 deletion src/mappers/Offset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { IDataValue, IMapper, IMapperConfig } from "./../Models";

export interface IOffsetConfig {
offset?: number | string;
}

export class Offset implements IMapper {
static ident: string = "OFFSET";
static description: string = "Offset number";
Expand All @@ -8,7 +12,7 @@ export class Offset implements IMapper {

constructor({
offset = "0",
} = {}) {
}: IOffsetConfig = {}) {
this.offset = parseInt(offset.toString(), 10);
}

Expand Down

0 comments on commit 2eaa150

Please sign in to comment.