GithubHelp home page GithubHelp logo

gkarthiks / isemptyobj Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 317 KB

https://gkarthiks.github.io/isEmptyObj/ Checks the given object is empty recursively (if needed) and returns true for empty.

License: MIT License

JavaScript 100.00%
is-empty is-empty-obj empty-check empty null null-check nullobject

isemptyobj's Introduction

isEmptyObj

node license Build Status

Checks the given object is empty recursively (if needed) and returns true for empty.

Why this?

This library checks the given variable or object for the null or empty. This will recursively goes into the object if needed and checks for the null / empty values. For example if an Object is having multiple levels and all those levels have just empty value, this will return true. Even at the least level, if it finds a value associated of with any type like Array or Object or String or even number this returns false.

Installation

npm i @gkarthiks/isemptyobj

Usage

var a = [];

var b = {};

var c = [{}];

var d = [{1:2}];

var e = { one: 1 };

var f = {
  source: {}, 
  type: 'typeValue', 
  pool: {}, 
  acquireConnectionTimeout: 30000, 
  system: [ {
            a: [1,2], 
            c: [5,6] 
            }, 
            2]
  };

var g = {
timeseries: {
  tillDate: ['val1', 'val2', 'val3', 'val4', 'val5']
  }
};

var h = {
  timeseries: {
    tillDate: [],
    }
};

var i = {
  a: [], 
  b:{ }
};

var j = {
  a: [], 
  b:{ 
    aa:[11],
    bb:{}
  }
};

var k = {
  system: [ {
            a: [1,2], 
            c: [5,6], 
            }, 
          2]
};

var l = {
      source: {}, 
      type: "", 
      pool: {},
      acquireConnectionTimeout: '', 
      system: [ {
        a: [], 
        c: []
        }, 
      ]
  };
isEmptyObj(a)         // => true
isEmptyObj(b)         // => true
isEmptyObj(c)         // => true
isEmptyObj(d)         // => false
isEmptyObj(e)         // => false
isEmptyObj(f)         // => false
isEmptyObj(g)         // => false
isEmptyObj(h)         // => true
isEmptyObj(i)         // => true
isEmptyObj(j)         // => false
isEmptyObj(k)         // => false
isEmptyObj(l)         // => true

isemptyobj's People

Contributors

dependabot[bot] avatar gkarthiks avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

isemptyobj's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.