1 | /**
|
2 | * Copyright 2013-present, Facebook, Inc.
|
3 | * All rights reserved.
|
4 | *
|
5 | * This source code is licensed under the BSD-style license found in the
|
6 | * LICENSE file in the root directory of this source tree. An additional grant
|
7 | * of patent rights can be found in the PATENTS file in the same directory.
|
8 | *
|
9 | */
|
10 |
|
11 | ;
|
12 |
|
13 | var ReactChildren = require('./ReactChildren');
|
14 |
|
15 | /**
|
16 | * Slice children that are typically specified as `props.children`. This version
|
17 | * of slice children ignores empty child components.
|
18 | *
|
19 | * @param {*} children The children set to filter.
|
20 | * @param {number} start The first zero-based index to include in the subset.
|
21 | * @param {?number} end The non-inclusive last index of the subset.
|
22 | * @return {object} mirrored array with mapped children
|
23 | */
|
24 | function sliceChildren(children, start, end) {
|
25 | if (children == null) {
|
26 | return children;
|
27 | }
|
28 |
|
29 | var array = ReactChildren.toArray(children);
|
30 | return array.slice(start, end);
|
31 | }
|
32 |
|
33 | module.exports = sliceChildren; |
\ | No newline at end of file |