UNPKG

393 BJavaScriptView Raw
1function isMany (names) {
2 const splitLinesMin = 3
3 return names.length > splitLinesMin
4}
5
6function printNames (label, names, log) {
7 if (!log) {
8 log = console.error.bind(console)
9 }
10 var sorted = names.sort()
11 const joiner = isMany(names) ? '\n - ' : ', '
12 if (isMany(sorted)) {
13 sorted = [''].concat(sorted)
14 }
15 log(label, sorted.join(joiner))
16}
17
18module.exports = printNames