JSPM

js-empty

1.0.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q19998F
  • License ISC

Check empty object, array, string,.. for nodejs

Package Exports

  • js-empty

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-empty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#JSEmpty for NodeJS

Check empty or null value of object, array, string,.. for NodeJS

Installation

$ npm install jsempty

API

var jsEmpty = require('jsempty');

jsEmpty(params [, options])

params: This is a object, array, string,..

options: Optionally, you can add an array index are ignored. This is a object or array.

Return

true: is empty

false: not empty

Example

Example 1

var params = {
    name:'MrTam',
    email:null
};
if(jsEmpty(params)){
    console.log('is empty');
}else{
    console.log('not empty');
}
// return is empty

Example 2

var params = {
    name:'MrTam',
    email:null
};
if(jsEmpty(params, ['email'])){
    console.log('is empty');
}else{
    console.log('not empty');
}
// return not empty

Example 3

var params = {
    name:'MrTam',
    email:null,
    birthday: {
        day: 10,
        month: 8,
        year: null
    }
};
if(jsEmpty(params, ['email'])){
    console.log('is empty');
}else{
    console.log('not empty');
}
// return is empty

Example 4

var params = {
    name:'MrTam',
    email:null,
    birthday: {
        day: 10,
        month: 8,
        year: null
    }
};
if(jsEmpty(params, {'email':'email', birthday:['year']})){
    console.log('is empty');
}else{
    console.log('not empty');
}
// return not empty

Example 5

var params = {
    name:'MrTam',
    email:null,
    birthday: {
        day: 10,
        month: 8,
        year: null
    }
};
if(jsEmpty(params, ['email', 'year'])){
    console.log('is empty');
}else{
    console.log('not empty');
}
// return not empty