1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = orList;
|
7 | /**
|
8 | * Copyright (c) 2015-present, Facebook, Inc.
|
9 | *
|
10 | * This source code is licensed under the MIT license found in the
|
11 | * LICENSE file in the root directory of this source tree.
|
12 | *
|
13 | *
|
14 | */
|
15 |
|
16 | var MAX_LENGTH = 5;
|
17 |
|
18 | /**
|
19 | * Given [ A, B, C ] return 'A, B, or C'.
|
20 | */
|
21 | function orList(items) {
|
22 | var selected = items.slice(0, MAX_LENGTH);
|
23 | return selected.reduce(function (list, quoted, index) {
|
24 | return list + (selected.length > 2 ? ', ' : ' ') + (index === selected.length - 1 ? 'or ' : '') + quoted;
|
25 | });
|
26 | } |
\ | No newline at end of file |