khali
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Khali (Khāli; meaning, Empty)

npm version install size npm downloads GitHub issues GitHub forks GitHub stars GitHub license Twitter

Simply check if your array, object, nested stuff, string, number, etc are empty or not.

Installation

  • with npm
    npm install khali
  • with yarn
    yarn add khali
  • with pnpm
    pnpm install khali
  • with bun
    bun add khali

Usage examples

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

API

isEmpty(value)

  • Returns boolean
  • Returns true if the value is empty else false.

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i khali

    Weekly Downloads

    7

    Version

    2.0.0

    License

    GPL-2.0-only

    Unpacked Size

    33 kB

    Total Files

    8

    Last publish

    Collaborators

    • mirashif
    • samiulhsohan