Skip to content

Commit

Permalink
trim num parser #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyaragupathy committed Feb 18, 2018
1 parent 6fb94b9 commit 161b712
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,19 @@ const numParser = (input) => {
let helperArr = ['','',0]
if (signParser(input[helperArr[2]]) === '-' || digitParser(input[helperArr[2]])) {
helperFunction(helperArr, input)
while ((digitParser(input[helperArr[2]]) || expParser(input[helperArr[2]]) || input[helperArr[2]] === '.') && helperArr[2] < input.length) {
helperFunction(helperArr,input)
}
while ((digitParser(input[helperArr[2]]) || expParser(input[helperArr[2]]) || input[helperArr[2]] === '.') && helperArr[2] < input.length) {helperFunction(helperArr,input)}
if (expParser(helperArr[0])) {
while ((digitParser(input[helperArr[2]]) || signParser(input[helperArr[2]])) && helperArr[2] < input.length) {
helperFunction(helperArr,input)
}
while ((digitParser(input[helperArr[2]]) || signParser(input[helperArr[2]])) && helperArr[2] < input.length) {helperFunction(helperArr,input)}
}
if (helperArr[1][0] === '0') {
if (digitParser(input[helperArr[2]])) {
return null
} else {
if (Number(helperArr[1]) >= 0) {
return [Number(helperArr[1]), input.slice(helperArr[2])]
} else return null
if (digitParser(input[helperArr[2]])) return null
else {
if (Number(helperArr[1]) >= 0) return [Number(helperArr[1]), input.slice(helperArr[2])]
else return null
}
}
return [Number(helperArr[1]), input.slice(helperArr[2])]
} else {
return null
}

} else return null
}

const strParser = (input) => {
Expand Down

0 comments on commit 161b712

Please sign in to comment.