123456789101112131415161718192021222324 |
- var forOwn = require('../object/forOwn');
- var isArray = require('./isArray');
- function isEmpty(val){
- if (val == null) {
- // typeof null == 'object' so we check it first
- return false;
- } else if ( typeof val === 'string' || isArray(val) ) {
- return !val.length;
- } else if ( typeof val === 'object' || typeof val === 'function' ) {
- var result = true;
- forOwn(val, function(){
- result = false;
- return false; // break loop
- });
- return result;
- } else {
- return false;
- }
- }
- module.exports = isEmpty;
|