diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-12-13 21:09:21 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-12-13 21:09:21 +0100 |
commit | 79446ca52cea0864ebe2540ba774cc386ee2f8bc (patch) | |
tree | 4bab98e360663ea2864a6c5b81825599932f2390 | |
parent | 8475676ac6d631e2a34db25662aa88359a5fd98d (diff) | |
download | browser-extension-79446ca52cea0864ebe2540ba774cc386ee2f8bc.tar.gz browser-extension-79446ca52cea0864ebe2540ba774cc386ee2f8bc.zip |
add `is_object_empty` utility function
-rw-r--r-- | common/misc.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/misc.js b/common/misc.js index a960d35..4d4b346 100644 --- a/common/misc.js +++ b/common/misc.js @@ -150,6 +150,17 @@ const matchers = { }; /* + * Facilitates checking if there aren't any keys in object. This does *NOT* + * account for pathological cases like redefined properties of Object prototype. + */ +function is_object_empty(object) +{ + for (const key in object) + return false; + return true; +} + +/* * EXPORTS_START * EXPORT gen_nonce * EXPORT make_csp_rule @@ -158,5 +169,6 @@ const matchers = { * EXPORT open_in_settings * EXPORT is_privileged_url * EXPORT matchers + * EXPORT is_object_empty * EXPORTS_END */ |