Skip to content

Commit d0980e4

Browse files
author
TFX-98
committed
FE-918 - lint files
1 parent 0ee6102 commit d0980e4

File tree

2 files changed

+87
-72
lines changed

2 files changed

+87
-72
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ext/process-response.ts

Lines changed: 85 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,159 +14,174 @@ import {
1414
TextResult,
1515
ChosenDocumentTypeResult,
1616
DocBarCodeInfo,
17-
TransactionInfo
17+
TransactionInfo,
1818
} from "../models/index.js";
19-
import {Text} from "./text.js";
20-
import {Images} from "./images.js";
19+
import { Text } from "./text.js";
20+
import { Images } from "./images.js";
2121
import * as converter from "base64-arraybuffer";
22-
import {Authenticity} from "./authenticity/authenticity.js";
23-
import * as pako from 'pako'
22+
import { Authenticity } from "./authenticity/authenticity.js";
23+
import * as pako from "pako";
2424

2525
export class Response {
26-
2726
// other future modules:
2827
// - authenticity
2928
// - document
30-
status?: Status
31-
text?: Text
32-
images?: Images
29+
status?: Status;
30+
text?: Text;
31+
images?: Images;
3332

34-
lowLvlResponse: LowLvlResponse
35-
rawResponse: ProcessResponse
33+
lowLvlResponse: LowLvlResponse;
34+
rawResponse: ProcessResponse;
3635

3736
constructor(original: ProcessResponse) {
37+
const lowLvlResponse = new LowLvlResponse(original);
38+
this.lowLvlResponse = lowLvlResponse;
39+
this.rawResponse = original;
3840

39-
const lowLvlResponse = new LowLvlResponse(original)
40-
this.lowLvlResponse = lowLvlResponse
41-
this.rawResponse = original
42-
43-
this.status = lowLvlResponse.statusResult()?.Status
44-
const textResult = lowLvlResponse.textResult()
41+
this.status = lowLvlResponse.statusResult()?.Status;
42+
const textResult = lowLvlResponse.textResult();
4543
if (textResult) {
46-
this.text = new Text(textResult.Text)
44+
this.text = new Text(textResult.Text);
4745
}
48-
const imagesResult = lowLvlResponse.imagesResult()
46+
const imagesResult = lowLvlResponse.imagesResult();
4947
if (imagesResult) {
50-
this.images = new Images(imagesResult.Images)
48+
this.images = new Images(imagesResult.Images);
5149
}
5250
}
5351

5452
public authenticity(page_idx = 0): Authenticity | undefined {
55-
const r = <AuthenticityResult>this.lowLvlResponse.resultByTypeAndPage(Result.AUTHENTICITY, page_idx)
53+
const r = <AuthenticityResult>(
54+
this.lowLvlResponse.resultByTypeAndPage(Result.AUTHENTICITY, page_idx)
55+
);
5656
if (r) {
57-
return new Authenticity(r.AuthenticityCheckList, page_idx)
57+
return new Authenticity(r.AuthenticityCheckList, page_idx);
5858
}
5959
}
6060

6161
public authenticityPerPage(): Array<Authenticity> {
62-
const filteredByTypeArray = <Array<AuthenticityResult>>this.lowLvlResponse.resultsByType(Result.AUTHENTICITY)
62+
const filteredByTypeArray = <Array<AuthenticityResult>>(
63+
this.lowLvlResponse.resultsByType(Result.AUTHENTICITY)
64+
);
6365

6466
return filteredByTypeArray
65-
.map((e: AuthenticityResult) => new Authenticity(e.AuthenticityCheckList, e.page_idx || 0))
66-
.sort((a, b) => a.page_idx - b.page_idx)
67+
.map(
68+
(e: AuthenticityResult) =>
69+
new Authenticity(e.AuthenticityCheckList, e.page_idx || 0)
70+
)
71+
.sort((a, b) => a.page_idx - b.page_idx);
6772
}
6873

6974
public imageQualityChecks(page_idx = 0): ImageQualityCheckList | undefined {
70-
const result = <ImageQualityResult>this.lowLvlResponse.resultByTypeAndPage(Result.IMAGE_QUALITY, page_idx)
75+
const result = <ImageQualityResult>(
76+
this.lowLvlResponse.resultByTypeAndPage(Result.IMAGE_QUALITY, page_idx)
77+
);
7178
if (result) {
7279
return result.ImageQualityCheckList;
7380
}
7481
}
7582

7683
public decodedLog(): string | undefined {
77-
const log = this.lowLvlResponse.log
84+
const log = this.lowLvlResponse.log;
7885
if (log) {
79-
const decoded = converter.decode(log)
80-
const uintArray = new Uint8Array(decoded)
86+
const decoded = converter.decode(log);
87+
const uintArray = new Uint8Array(decoded);
8188

82-
let dataUintArray
89+
let dataUintArray;
8390
try {
84-
const currentDataUintArray = pako.inflate(uintArray)
85-
86-
dataUintArray =
87-
currentDataUintArray.length > uintArray.length
88-
? currentDataUintArray
89-
: uintArray
91+
const currentDataUintArray = pako.inflate(uintArray);
9092

93+
dataUintArray =
94+
currentDataUintArray.length > uintArray.length
95+
? currentDataUintArray
96+
: uintArray;
9197
} catch (err) {
92-
dataUintArray = uintArray
98+
dataUintArray = uintArray;
9399
}
94100

95-
const uintArraySize = dataUintArray.length
96-
const step = 10000
97-
const result = []
98-
const convertedUnitArray = [].slice.call(dataUintArray)
101+
const uintArraySize = dataUintArray.length;
102+
const step = 10000;
103+
const result = [];
104+
const convertedUnitArray = [].slice.call(dataUintArray);
99105
// To avoid maximum call stack size excess
100106
for (let i = 0; i < uintArraySize; i += step) {
101-
const chunk = String.fromCharCode.apply(null, convertedUnitArray.slice(i, i + step))
102-
result.push(chunk)
107+
const chunk = String.fromCharCode.apply(
108+
null,
109+
convertedUnitArray.slice(i, i + step)
110+
);
111+
result.push(chunk);
103112
}
104-
return result.join('')
113+
return result.join("");
105114
} else {
106-
return undefined
115+
return undefined;
107116
}
108117
}
109118
}
110119

111120
export class LowLvlResponse implements ProcessResponse {
112-
113-
ContainerList: ContainerList
114-
ProcessingFinished: ProcessingStatus
115-
TransactionInfo: TransactionInfo
116-
ChipPage?: RfidLocation
117-
log?: string
118-
passBackObject?: { [key: string]: any; };
121+
ContainerList: ContainerList;
122+
ProcessingFinished: ProcessingStatus;
123+
TransactionInfo: TransactionInfo;
124+
ChipPage?: RfidLocation;
125+
log?: string;
126+
passBackObject?: { [key: string]: any };
119127
morePagesAvailable?: number;
120128

121129
constructor(original: ProcessResponse) {
122-
this.ContainerList = original.ContainerList
123-
this.ProcessingFinished = original.ProcessingFinished
124-
this.TransactionInfo = original.TransactionInfo
125-
this.ChipPage = original.ChipPage
126-
this.log = original.log
127-
this.passBackObject = original.passBackObject
128-
this.morePagesAvailable = original.morePagesAvailable
130+
this.ContainerList = original.ContainerList;
131+
this.ProcessingFinished = original.ProcessingFinished;
132+
this.TransactionInfo = original.TransactionInfo;
133+
this.ChipPage = original.ChipPage;
134+
this.log = original.log;
135+
this.passBackObject = original.passBackObject;
136+
this.morePagesAvailable = original.morePagesAvailable;
129137
}
130138

131139
public statusResult(): StatusResult | undefined {
132-
return <StatusResult>this.resultByType(Result.STATUS)
140+
return <StatusResult>this.resultByType(Result.STATUS);
133141
}
134142

135143
public textResult(): TextResult | undefined {
136-
return <TextResult>this.resultByType(Result.TEXT)
144+
return <TextResult>this.resultByType(Result.TEXT);
137145
}
138146

139147
public imagesResult(): ImagesResult | undefined {
140-
return <ImagesResult>this.resultByType(Result.IMAGES)
148+
return <ImagesResult>this.resultByType(Result.IMAGES);
141149
}
142150

143151
public barcodeResult(): DocBarCodeInfo | undefined {
144-
return <DocBarCodeInfo>this.resultByType(Result.BARCODES)
152+
return <DocBarCodeInfo>this.resultByType(Result.BARCODES);
145153
}
146154

147155
public documentTypeResults(): Array<ChosenDocumentTypeResult> | undefined {
148-
return <Array<ChosenDocumentTypeResult>>this.resultsByType(Result.DOCUMENT_TYPE)
156+
return <Array<ChosenDocumentTypeResult>>(
157+
this.resultsByType(Result.DOCUMENT_TYPE)
158+
);
149159
}
150160

151161
public resultByType(type: Result): ResultItem | undefined {
152162
for (const container of this.ContainerList.List) {
153163
if (container.result_type === type) {
154-
return container
164+
return container;
155165
}
156166
}
157-
return undefined
167+
return undefined;
158168
}
159169

160-
public resultByTypeAndPage(type: Result, page_idx = 0): ResultItem | undefined {
170+
public resultByTypeAndPage(
171+
type: Result,
172+
page_idx = 0
173+
): ResultItem | undefined {
161174
for (const container of this.ContainerList.List) {
162175
if (container.result_type === type && container.page_idx == page_idx) {
163-
return container
176+
return container;
164177
}
165178
}
166-
return undefined
179+
return undefined;
167180
}
168181

169182
public resultsByType(type: Result): Array<ResultItem | AuthenticityResult> {
170-
return this.ContainerList.List.filter(container => container.result_type === type)
183+
return this.ContainerList.List.filter(
184+
(container) => container.result_type === type
185+
);
171186
}
172187
}

0 commit comments

Comments
 (0)