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:
754 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * The base implementation of `_.slice` without an iteratee call guard.
|
---|
| 3 | *
|
---|
| 4 | * @private
|
---|
| 5 | * @param {Array} array The array to slice.
|
---|
| 6 | * @param {number} [start=0] The start position.
|
---|
| 7 | * @param {number} [end=array.length] The end position.
|
---|
| 8 | * @returns {Array} Returns the slice of `array`.
|
---|
| 9 | */
|
---|
| 10 | function baseSlice(array, start, end) {
|
---|
| 11 | var index = -1,
|
---|
| 12 | length = array.length;
|
---|
| 13 |
|
---|
| 14 | if (start < 0) {
|
---|
| 15 | start = -start > length ? 0 : (length + start);
|
---|
| 16 | }
|
---|
| 17 | end = end > length ? length : end;
|
---|
| 18 | if (end < 0) {
|
---|
| 19 | end += length;
|
---|
| 20 | }
|
---|
| 21 | length = start > end ? 0 : ((end - start) >>> 0);
|
---|
| 22 | start >>>= 0;
|
---|
| 23 |
|
---|
| 24 | var result = Array(length);
|
---|
| 25 | while (++index < length) {
|
---|
| 26 | result[index] = array[index + start];
|
---|
| 27 | }
|
---|
| 28 | return result;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | export default baseSlice;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.