Simply check if your array, object, nested stuff, string, number, etc are empty or not.
- with npm
npm install khali
- with yarn
yarn add khali
- with pnpm
pnpm install khali
- with bun
bun add khali
import isEmpty from "khali";
// Regular stuff
isEmpty([]); // true
isEmpty({}); // true
isEmpty(""); // true
isEmpty(0); // true
const arr = ["Dhaka", ["Uttara", [1, 2]]];
const obj = {
city: "Dhaka",
location: {
latitude: "23.809473999508782",
longitude: "90.4151957081839",
},
};
// It works with array or, object
isEmpty(arr[10]); // true
isEmpty(obj["capital"]); // true
isEmpty(arr); // false
isEmpty(obj); // false
// And of course it works with nested values
isEmpty(arr[0][100]); // true
isEmpty(obj["location"]["area"]); // true
isEmpty(arr[0][0]); // false
isEmpty(obj.city); // false
- Returns
boolean
- Returns
true
if thevalue
is empty elsefalse
.