-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return false for non-empty objects (#143)
* Return false for non-empty objects * Check that properties are empty. Rather than the object itself. * Refactor hasEmptyProperty. Add test * Fix minor typo
- Loading branch information
1 parent
e93291f
commit 95727cc
Showing
3 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Checks if there is any properties of @obj that is a empty object | ||
* @function | ||
* @param {object} obj - the object to check | ||
*/ | ||
function hasEmptyProperty(obj) { | ||
return Object.values(obj).every( | ||
keyObject => | ||
typeof keyObject === 'object' && | ||
Object.keys(keyObject).every(key => !(key in keyObject)) | ||
); | ||
} | ||
|
||
module.exports = hasEmptyProperty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters