git ssb

1+

Daan Patchwork / patchwork



Tree: 55fc93a9190c25f467ead205ab8d676b5191dbd4

Files: 55fc93a9190c25f467ead205ab8d676b5191dbd4 / lib / many.js

875 bytesRaw
1module.exports = function many (ids, fn, intl) {
2 ids = Array.from(ids)
3 const featuredIds = ids.slice(0, 4)
4
5 if (ids.length) {
6 if (ids.length > 4) {
7 return [
8 fn(featuredIds[0]), ', ',
9 fn(featuredIds[1]), ', ',
10 fn(featuredIds[2]), intl(' and '),
11 ids.length - 3, intl(' others')
12 ]
13 } else if (ids.length === 4) {
14 return [
15 fn(featuredIds[0]), ', ',
16 fn(featuredIds[1]), ', ',
17 fn(featuredIds[2]), intl(' and '),
18 fn(featuredIds[3])
19 ]
20 } else if (ids.length === 3) {
21 return [
22 fn(featuredIds[0]), ', ',
23 fn(featuredIds[1]), intl(' and '),
24 fn(featuredIds[2])
25 ]
26 } else if (ids.length === 2) {
27 return [
28 fn(featuredIds[0]), intl(' and '),
29 fn(featuredIds[1])
30 ]
31 } else {
32 return fn(featuredIds[0])
33 }
34 }
35}
36

Built with git-ssb-web