10 lines
186 B
JavaScript
10 lines
186 B
JavaScript
|
|
||
|
function convertToIntegerIfNumber(str) {
|
||
|
if (/^\d+$/.test(str)) {
|
||
|
return parseInt(str, 10)
|
||
|
} else {
|
||
|
return str
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = convertToIntegerIfNumber
|