678e7c79d3320e948d43aab2a333f47689974977
[yaffs-website] / node_modules / uncss / node_modules / lodash / slice.js
1 var baseSlice = require('./internal/baseSlice'),
2     isIterateeCall = require('./internal/isIterateeCall'),
3     toInteger = require('./toInteger');
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 [`Array#slice`](https://mdn.io/Array/slice)
9  * to ensure dense arrays are returned.
10  *
11  * @static
12  * @memberOf _
13  * @category Array
14  * @param {Array} array The array to slice.
15  * @param {number} [start=0] The start position.
16  * @param {number} [end=array.length] The end position.
17  * @returns {Array} Returns the slice of `array`.
18  */
19 function slice(array, start, end) {
20   var length = array ? array.length : 0;
21   if (!length) {
22     return [];
23   }
24   if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
25     start = 0;
26     end = length;
27   }
28   else {
29     start = start == null ? 0 : toInteger(start);
30     end = end === undefined ? length : toInteger(end);
31   }
32   return baseSlice(array, start, end);
33 }
34
35 module.exports = slice;