Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

22
node_modules/es-toolkit/dist/compat/array/nth.mjs generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { toInteger } from "../util/toInteger.mjs";
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
//#region src/compat/array/nth.ts
/**
* Gets the element at index `n` of `array`. If `n` is negative, the nth element from the end is returned.
*
* @param {ArrayLike<T> | null | undefined} array - The array to query.
* @param {number} [n=0] - The index of the element to return.
* @return {T | undefined} Returns the nth element of `array`.
*
* @example
* nth([1, 2, 3], 1); // => 2
* nth([1, 2, 3], -1); // => 3
*/
function nth(array, n = 0) {
if (!isArrayLikeObject(array) || array.length === 0) return;
n = toInteger(n);
if (n < 0) n += array.length;
return array[n];
}
//#endregion
export { nth };