Skip to content

Commit

Permalink
Added isEmptyObject()
Browse files Browse the repository at this point in the history
  • Loading branch information
lupusA committed Sep 25, 2023
1 parent 856a5fb commit 9985cea
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/PoliciesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,28 @@ export class PoliciesTable extends Component {

policySummary(policies) {
let bits = [];
/**
* Check if the object is empty
* @param {*} obj
* @returns true if the object is empty
*/
function isEmptyObject(obj) {
return (
Object.getPrototypeOf(obj) === Object.prototype &&
Object.getOwnPropertyNames(obj).length === 0 &&
Object.getOwnPropertySymbols(obj).length === 0
);
}
/**
* Check if object has it's key as a property.
* However, if the object itself is a set of sets, it has to be checked by isEmptyObject()
* @param {*} obj
* @returns
*/
function isEmpty(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return false;
return isEmptyObject(obj[key]);
}
return true;
}
Expand Down

0 comments on commit 9985cea

Please sign in to comment.