Skip to content

Commit 747eb1c

Browse files
Lint corrections
Lint corrections
1 parent 1657775 commit 747eb1c

File tree

3 files changed

+40
-54
lines changed

3 files changed

+40
-54
lines changed

Diff for: src/core/lib/Base94.mjs

+38-52
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,39 @@ export function toBase94(data, strictLength=true) {
2828

2929
if (data instanceof ArrayBuffer) {
3030
data = new Uint8Array(data);
31+
} else {
32+
throw new OperationError(`Invalid - Input not instanceof ArrayBuffer.`);
3133
}
32-
else
33-
{
34-
throw new OperationError(`Invalid - Input not instanceof ArrayBuffer.`);
35-
}
36-
37-
let dataModLen = data.length % 4;
3834

39-
if (dataModLen > 0 && strictLength)
40-
{
35+
const dataModLen = data.length % 4;
4136

37+
if (dataModLen > 0 && strictLength) {
4238
throw new OperationError(`Invalid - Input byte length must be a multiple of 4.`);
43-
4439
}
4540

4641
let output = "", i = 0, j = 0, acc = 0;
4742

48-
let dataPad = new Uint8Array(data.length + (dataModLen > 0 ? (4 - dataModLen) : 0));
43+
const dataPad = new Uint8Array(data.length + (dataModLen > 0 ? (4 - dataModLen) : 0));
4944

50-
dataPad.set(data,0);
45+
dataPad.set(data, 0);
5146

5247
while (i < dataPad.length) {
5348

5449
acc = 0;
5550

56-
for(j = 0; j < 4; j++)
57-
{
51+
for (j = 0; j < 4; j++) {
5852

59-
acc *= 256;
53+
acc *= 256;
6054

61-
acc += dataPad[i + (3 - j)];
55+
acc += dataPad[i + (3 - j)];
6256

6357
}
6458

65-
for(j = 0; j < 5; j++)
66-
{
59+
for (j = 0; j < 5; j++) {
6760

68-
output += String.fromCharCode((acc % 94)+32);
61+
output += String.fromCharCode((acc % 94)+32);
6962

70-
acc = Math.floor(acc / 94);
63+
acc = Math.floor(acc / 94);
7164

7265
}
7366

@@ -105,73 +98,66 @@ export function fromBase94(data, strictLength=true, removeInvalidChars=false) {
10598

10699
data = Utils.strToByteArray(data);
107100

108-
}
109-
else {
101+
} else {
110102

111-
throw new OperationError(`Invalid - typeof base94 input is not a string.`);
103+
throw new OperationError(`Invalid - typeof base94 input is not a string.`);
112104

113105
}
114106

115107
const re = new RegExp("[^\x20-\x7e]", "g");
116108

117-
if(re.test(data))
118-
{
119-
if (removeInvalidChars) {
120-
data = data.replace(re, "");
121-
}
122-
else {
123-
throw new OperationError(`Invalid content in Base94 string.`);
124-
}
109+
if (re.test(data)) {
110+
if (removeInvalidChars) {
111+
data = data.replace(re, "");
112+
} else {
113+
throw new OperationError(`Invalid content in Base94 string.`);
114+
}
125115
}
126116

127117
let stringModLen = data.length % 5;
128118

129-
if (stringModLen > 0)
130-
{
119+
if (stringModLen > 0) {
131120

132-
if(strictLength)
133-
{
134-
throw new OperationError(`Invalid - Input string length must be a multiple of 5.`);
135-
}
121+
if (strictLength) {
122+
throw new OperationError(`Invalid - Input string length must be a multiple of 5.`);
123+
}
136124

137-
stringModLen = 5 - stringModLen;
125+
stringModLen = 5 - stringModLen;
138126

139-
while(stringModLen > 0)
140-
{
127+
while (stringModLen > 0) {
141128

142-
data.push(32);
129+
data.push(32);
143130

144-
stringModLen -= 1;
131+
stringModLen -= 1;
145132

146-
}
133+
}
147134

148135
}
149136

150-
let output = [], i = 0, j = 0, acc = 0;
137+
const output = [];
138+
let i = 0, j = 0, acc = 0;
151139

152140
while (i < data.length) {
153141

154-
acc = 0;
142+
acc = 0;
155143

156-
for (j = 0; j < 5; j++)
157-
{
144+
for (j = 0; j < 5; j++) {
158145

159146
acc = (acc * 94) + data[i + 4 - j] - 32;
160147

161-
}
148+
}
162149

163-
for (j = 0; j < 4; j++)
164-
{
150+
for (j = 0; j < 4; j++) {
165151

166152
output.push(acc % 256);
167153

168154
acc = Math.floor(acc / 256);
169155

170-
}
156+
}
171157

172-
i += 5;
158+
i += 5;
173159

174-
}
160+
}
175161

176162
return output;
177163

Diff for: src/core/operations/FromBase94.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FromBase94 extends Operation {
4444
*/
4545
run(input, args) {
4646

47-
const [strictLength,removeInvalidChars] = args;
47+
const [strictLength, removeInvalidChars] = args;
4848

4949
return fromBase94(input, strictLength, removeInvalidChars);
5050

Diff for: src/core/operations/ToBase94.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ToBase94 extends Operation {
3939
*/
4040
run(input, args) {
4141
const [strictLength] = args;
42-
return toBase94(input,strictLength);
42+
return toBase94(input, strictLength);
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)