Skip to content

Commit 6e470fb

Browse files
committed
feat: tidy TODOs
1 parent 3fabc38 commit 6e470fb

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const getActionType = (keyInfo: IKeyInfo, options: IOptions): ActionType
5959
return foundType ? foundType.type : ActionType.UNKNOWN;
6060
};
6161

62-
// TODO: consistent type for handler functions?
6362
export const getHandlerForAction = (action: ActionType): ActionHandler => {
6463
const handlerForAction = {
6564
[ActionType.NUMBER]: keyHandlers.onNumber,

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// TODO: do these need to be string enum?
21
export enum Key {
32
NUMPAD_ADD = "add",
43
NUMPAD_SUBTRACT = "subtract",

src/helpers.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const formatThousands = (val: string, options: IOptions): string => {
3232

3333
export const partialFormat = (val: string, options: IOptions): string => {
3434
val = val.replace(new RegExp(`[${options.thousands}]`, "g"), "");
35-
val = removeleadingZeros(val, options);
35+
val = removeLeadingZeros(val, options);
3636
val = removeExtraDecimals(val, options);
3737
val = formatThousands(val, options);
3838

@@ -73,16 +73,14 @@ export const fullFormat = (val: string, options: IOptions): string => {
7373
}
7474
};
7575

76-
// TODO: fix typoes
77-
export const removeleadingZeros = (val: string, options: IOptions): string => {
76+
const removeLeadingZeros = (val: string, options: IOptions): string => {
7877
const decimalIndex = getDecimalIndex(val, options.decimal);
7978
const sign = val[0] === "-" ? val[0] : "";
8079
let integerPart = val.slice(sign ? 1 : 0, decimalIndex + 1);
8180
const decimalPart = val.slice(decimalIndex + 1);
8281

8382
const i = 0;
8483

85-
// TODO: investigate compile error with == 0
8684
while (
8785
integerPart[i] === "0"
8886
&& integerPart[i + 1] !== options.decimal
@@ -94,7 +92,7 @@ export const removeleadingZeros = (val: string, options: IOptions): string => {
9492
return `${sign}${integerPart}${decimalPart}`;
9593
};
9694

97-
export const removeExtraDecimals = (val: string, options: IOptions): string => {
95+
const removeExtraDecimals = (val: string, options: IOptions): string => {
9896
const decimalIndex = getDecimalIndex(val, options.decimal);
9997
const integerPart = val.slice(0, decimalIndex + 1);
10098
const decimalPart = val.slice(decimalIndex + 1)
@@ -140,7 +138,6 @@ export const allowedZero = (val: string, char: string, caretPos: number, options
140138
if ((integerPart.length > 0) && (caretPos < integerPart.length + 1)) {
141139
// IF integer part is just a zero then no zeros can be added
142140
// ELSE the zero can not be added at the front of the value
143-
// TODO: investigate compile error with == 0
144141
return integerPart === "0" ? false : caretPos > 0;
145142
} else {
146143
return true;
@@ -187,8 +184,7 @@ export const parseString = (str: string, options: IOptions): string => {
187184
let parsed = "";
188185

189186
for (const c of str) {
190-
// TODO: type c properly
191-
if (!isNaN(c as any)) { // If a number
187+
if (!isNaN(Number(c))) { // If a number
192188
parsed += c;
193189
} else if (c === options.decimal && parsed.indexOf(c) === -1) { // If a decimal (and no decimals exist so far)
194190
parsed += options.decimal;

0 commit comments

Comments
 (0)