summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-08 15:23:59 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-08 16:01:29 -0500
commit0156869a3d8c4236594035e072b084b7c2ea8f16 (patch)
tree58695662f01fe90b0b3fa7340059d14f9ca23e09 /ext
parentdbd9a5414938df1613866743a0c8a2a683101ac1 (diff)
Optimize utilIsolate
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/util.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 8175fdff..93bb7047 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -16,8 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-function utilIsolate(data) {
- return JSON.parse(JSON.stringify(data));
+function utilIsolate(value) {
+ if (value === null) { return null; }
+
+ switch (typeof value) {
+ case 'boolean':
+ case 'number':
+ case 'string':
+ case 'bigint':
+ case 'symbol':
+ return value;
+ }
+
+ const stringValue = JSON.stringify(value);
+ return typeof stringValue === 'string' ? JSON.parse(stringValue) : null;
}
function utilBackgroundIsolate(data) {