UNPKG

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