Lightweight array utilities (isEmpty, isNotEmpty, etc.)
npm install array-kit-liteš¦ array-kit# š¦ array-kit
A lightweight utility library for common array operations like isEmpty, isNotEmpty, first, last, and unique.
Designed to be minimal, typed, and framework-agnostic ā a tiny alternative to Lodash for array checks.
---
bash
npm install array-kit
`
$3
`bash
pnpm add array-kit
`
$3
`bash
yarn add array-kit
`
$3
`bash
bun add array-kit
`
$3
`bash
deno add jsr:@your-username/array-kit
`
⨠Features
ā
TypeScript support out of the box
ā
Works in Node.js, Deno, and modern browsers
ā
Tiny footprint ā only the essentials
ā
Tree-shakeable
$3
`ts
// ESM / TypeScript
import { isEmpty, isNotEmpty, first, last, unique } from "array-kit";
// CommonJS
const { isEmpty, isNotEmpty } = require("array-kit");
`
$3
`ts
isEmpty([]); // true
isNotEmpty([1, 2, 3]); // true
first([10, 20, 30]); // 10
last([10, 20, 30]); // 30
unique([1, 1, 2, 3, 3]); // [1, 2, 3]
`
API
| Function | Description |
| ----------------- | ------------------------------------------------------------ |
| isEmpty(arr) | Returns true if the array is null, undefined, or empty |
| isNotEmpty(arr) | Returns true if the array contains at least one element |
| first(arr) | Returns the first element, or undefined if empty |
| last(arr) | Returns the last element, or undefined if empty |
| unique(arr)` | Returns a new array with duplicates removed |