UNPKG

typedash

Version:

modern, type-safe collection of utility functions

25 lines (23 loc) 557 B
//#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 Object.defineProperty(exports, 'take', { enumerable: true, get: function () { return take; } }); //# sourceMappingURL=take-C7R3cR8n.cjs.map