typedash
Version:
modern, type-safe collection of utility functions
19 lines (18 loc) • 470 B
JavaScript
//#region src/functions/take/take.ts
/**
* Returns the first `count` items from `array`.
* @param array The array to take items from.
* @param count The number of items to take.
* @returns The first `count` items from `array`.
* @example
* ```ts
* take([1, 2, 3, 4, 5], 3) // [1, 2, 3]
* ```
*/
function take(array, count) {
if (count <= 0) return [];
return array?.slice(0, count) ?? [];
}
//#endregion
export { take as t };
//# sourceMappingURL=take-BFYarbpB.js.map