Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
756 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 | module.exports = baseSlice;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.