UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

12 lines (9 loc) 286 B
import { toInteger } from '../compat/util/toInteger.mjs'; function takeRight(arr, count, guard) { count = guard || count === undefined ? 1 : toInteger(count); if (count <= 0 || arr.length === 0) { return []; } return arr.slice(-count); } export { takeRight };