/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

/**
 * Takes the last N items from an array.
 *
 * @param count - Number of items to take from the end.
 * @param array - The array to take items from.
 * @returns A new array with the last N items.
 */
export function takeLast( count, array ) {
	if ( count <= 0 || !Array.isArray( array ) ) {
		return [];
	}

	return array.slice( -count );
}
