summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-06-28 12:38:34 -0400
committerGitHub <noreply@github.com>2020-06-28 12:38:34 -0400
commitcdf191336aa616a206b977ba3beeb1233cf41c32 (patch)
tree07df9e5eec80dd4379c7ed97854a2bd9ef5149eb /ext/bg/js/util.js
parent5bf805755a33f6f10fd9621f8a2bff7ba1cb7440 (diff)
Clone function (#624)
* Add clone function * Replace utilIsolate with clone * Replace JsonSchema.isolate with clone function * Include core.js for tests which use json-schema.js * Update visisted set
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js20
1 files changed, 2 insertions, 18 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index edc19c6e..fa31b0d8 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -15,26 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-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 utilFunctionIsolate(func) {
return function isolatedFunction(...args) {
try {
- args = args.map((v) => utilIsolate(v));
+ args = args.map((v) => clone(v));
return func.call(this, ...args);
} catch (e) {
try {
@@ -50,7 +34,7 @@ function utilFunctionIsolate(func) {
function utilBackgroundIsolate(data) {
const backgroundPage = chrome.extension.getBackgroundPage();
- return backgroundPage.utilIsolate(data);
+ return backgroundPage.clone(data);
}
function utilBackgroundFunctionIsolate(func) {