main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | import baseSlice from './_baseSlice.js';
|
---|
| 2 | import isIterateeCall from './_isIterateeCall.js';
|
---|
| 3 | import toInteger from './toInteger.js';
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * Creates a slice of `array` from `start` up to, but not including, `end`.
|
---|
| 7 | *
|
---|
| 8 | * **Note:** This method is used instead of
|
---|
| 9 | * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
|
---|
| 10 | * returned.
|
---|
| 11 | *
|
---|
| 12 | * @static
|
---|
| 13 | * @memberOf _
|
---|
| 14 | * @since 3.0.0
|
---|
| 15 | * @category Array
|
---|
| 16 | * @param {Array} array The array to slice.
|
---|
| 17 | * @param {number} [start=0] The start position.
|
---|
| 18 | * @param {number} [end=array.length] The end position.
|
---|
| 19 | * @returns {Array} Returns the slice of `array`.
|
---|
| 20 | */
|
---|
| 21 | function slice(array, start, end) {
|
---|
| 22 | var length = array == null ? 0 : array.length;
|
---|
| 23 | if (!length) {
|
---|
| 24 | return [];
|
---|
| 25 | }
|
---|
| 26 | if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
---|
| 27 | start = 0;
|
---|
| 28 | end = length;
|
---|
| 29 | }
|
---|
| 30 | else {
|
---|
| 31 | start = start == null ? 0 : toInteger(start);
|
---|
| 32 | end = end === undefined ? length : toInteger(end);
|
---|
| 33 | }
|
---|
| 34 | return baseSlice(array, start, end);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | export default slice;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.