A TypeScript utility library providing a comprehensive set of functions to validate, verify, and perform checks on array. This package provides simple and effective tools to help you manage arrays and iteration logic with ease.
NPM:
npx jsr add @checker/arrayPNPM:
pnpm dlx jsr add @checker/arrayDeno:
deno add @checker/arrayYarn:
yarn dlx jsr add @checker/arrayBun:
bunx jsr add @checker/arrayChecks if the given value is an array.
check_is_array([1, 2, 3]); // true
check_is_array(42); // falseChecks if the given value is not an array.
check_is_not_array(42); // true
check_is_not_array([1, 2, 3]); // falseChecks if the given array is empty.
check_is_empty([]); // true
check_is_empty([1, 2, 3]); // falseChecks if the given array is not empty.
check_is_not_empty([1, 2, 3]); // true
check_is_not_empty([]); // falseChecks if the given index corresponds to the first iteration.
check_is_first_iteration(0); // true
check_is_first_iteration(1); // falseconst numbers = [1, 2, 3];
numbers.map((number, index) => {
if (check_is_first_iteration(index)) {
return number + 1;
}
return number;
});
// => [2, 2, 3]Checks if the given index does not correspond to the first iteration.
check_is_not_first_iteration(1); // true
check_is_not_first_iteration(0); // falseconst numbers = [1, 2, 3];
numbers.map((number, index) => {
if (check_is_not_first_iteration(index)) {
return number + 1;
}
return number;
});
// => [1, 3, 4]Checks if an array contains a specific value.
check_array_has_value([1, 2, 3], 2); // true
check_array_has_value([1, 2, 3], 4); // falseChecks if an array does not contain a specific value.
check_array_does_not_have_value([1, 2, 3], 4); // true
check_array_does_not_have_value([1, 2, 3], 2); // falseChecks if the given index is the last iteration in the array.
check_is_last_iteration(2, [10, 20, 30]); // true
check_is_last_iteration(1, [10, 20, 30]); // falseChecks if the given index is not the last iteration in the array.
check_is_not_last_iteration(1, [10, 20, 30]); // true
check_is_not_last_iteration(2, [10, 20, 30]); // falseChecks if the current iteration index matches a specific target index.
check_is_specific_iteration(3, 3); // true
check_is_specific_iteration(2, 3); // falseconst numbers = [1, 2, 3];
numbers.map((number, index) => {
if (check_is_specific_iteration(index, 1)) {
return number + 1;
}
return number;
});
// => [1, 3, 3]Checks if the current iteration index does not match a specific target index.
check_is_not_specific_iteration(2, 3); // true
check_is_not_specific_iteration(3, 3); // falseconst numbers = [1, 2, 3];
numbers.map((number, index) => {
if (check_is_specific_iteration(index, 1)) {
return number + 1;
}
return number;
});
// => [2, 2, 4]MIT License