super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
26 lines (25 loc) • 557 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.slice = slice;
/**
* Creates a slice of array from start up to, but not including, end.
*
* @param array - The array to slice
* @param start - The start position
* @param end - The end position
* @returns The slice of array
*
* @example
* ```ts
* const arr = [1, 2, 3, 4];
*
* slice(arr, 1, 3);
* // => [2, 3]
* ```
*/
function slice(array, start = 0, end) {
if (!array || !array.length) {
return [];
}
return array.slice(start, end);
}