From ff398191f2c0547b0164e487414aec37a030bf65 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 1 Feb 2017 09:43:33 +0100 Subject: [PATCH] Return an empty object when failing to determine global scope. --- papaparse.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/papaparse.js b/papaparse.js index 59a846c..ab0578b 100644 --- a/papaparse.js +++ b/papaparse.js @@ -35,10 +35,11 @@ if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } - throw new Error('Cannot determine global object'); + // When running tests none of the above have been defined + return {}; })(); - - + + var IS_WORKER = !global.document && !!global.postMessage, IS_PAPA_WORKER = IS_WORKER && /(\?|&)papaworker(=|&|$)/.test(global.location.search), LOADED_SYNC = false, AUTO_SCRIPT_PATH;