UNPKG

325 BJavaScriptView Raw
1function isNumeric(num) {
2 return !isNaN(num);
3}
4
5function safeToNumber(num) {
6 if (isNumeric(num)) {
7 return Number(num);
8 }
9
10 return num;
11}
12
13function safeToArray(field) {
14 if (typeof field === "string") {
15 return [field];
16 }
17
18 return field;
19}
20
21module.exports = {
22 isNumeric,
23 safeToNumber,
24 safeToArray,
25};