Skip to content

Commit

Permalink
feat(empty): add empty function
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hamilton committed Nov 29, 2018
1 parent aa7170a commit 055a50a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// o
import is from './is';
import size from './size';

/**
* Check if an object is empty (has no keys)
*
* @param {object} object The object to check
*
* @returns {boolean} Whether it is empty
*/
function empty(object) {
// check if the object specified is an object
if (is(object)) {
// if it is get the size of the object and return true if it
// is larger then 0 meaning it isn't empty
return !(size(object) > 0);
}

// return false if the object isn't an object
return false;
}

export default empty;

0 comments on commit 055a50a

Please # to comment.