From ec4c72e5bf92668dbc51ade16690f2ea510c635f Mon Sep 17 00:00:00 2001 From: Rob Dupuis Date: Wed, 18 Feb 2015 21:03:14 +0000 Subject: [PATCH] Do not set IS_WORKER when PapaParse is loaded as a node module The existing check, that there was no global.document, incorrectly identified PapaParse as running in a web worker when loaded by node. Checking for the availability of the postMessage() method (which we rely on already) fixes this, whilst not exposing us to any more of the WebWorker API. --- papaparse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/papaparse.js b/papaparse.js index 88d06db..96b6c80 100644 --- a/papaparse.js +++ b/papaparse.js @@ -7,7 +7,7 @@ { "use strict"; - var IS_WORKER = !global.document, LOADED_SYNC = false, AUTO_SCRIPT_PATH; + var IS_WORKER = (!global.document && !!global.postMessage), LOADED_SYNC = false, AUTO_SCRIPT_PATH; var workers = {}, workerIdCounter = 0; var Papa = {};