-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUtils.js
More file actions
32 lines (27 loc) · 763 Bytes
/
Utils.js
File metadata and controls
32 lines (27 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function prettyJoin(list){
var outputString = ""
if(list.length >= 2){
for (let i = 0; i < list.length; i++) {
const el = list[i];
if(i == 0){
outputString += "'" + el + "'"
} else if( i != list.length - 1) {
outputString += ", " + "'" + el + "'"
} else {
outputString += " or " + "'" + el + "'"
}
}
} else {
outputString = "only '" + list[0] + "'"
}
return outputString
}
function isNumeric(value) {
return /^\d+$/.test(value);
}
function alignMenu(menuOutput){
return menuOutput.split('\n')
.map(line => line.trimStart())
.join('\n')
}
module.exports = {prettyJoin, isNumeric, alignMenu}