Skip to content

Commit

Permalink
Fix isBrowser logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreen7 committed Apr 7, 2021
1 parent 5684ff6 commit 51e1e9d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/parsers/anyToJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import extractFileExtension from "./utils/extractFileExtension.js";
import snapgeneToJson from "./snapgeneToJson";
import ab1ToJson from "./ab1ToJson";
import gffToJson from "./gffToJson";
import isBrowser from "./utils/isBrowser";

/**
* takes in file content string and its file name and determines what parser it needs to be sent to.
Expand Down Expand Up @@ -118,7 +119,7 @@ async function anyToJson(fileContentStringOrFileObj, options) {
export default anyToJson;

function getUtf8StringFromFile(file, { emulateBrowser } = {}) {
if (typeof process === "object" && !emulateBrowser) {
if (!isBrowser && !emulateBrowser) {
//emulate browser is only used for testing purposes
//we're in a node context
return Buffer.isBuffer(file)
Expand Down
4 changes: 3 additions & 1 deletion src/parsers/utils/getArrayBufferFromFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import isBrowser from "./isBrowser";

export default function getArrayBufferFromFile(file) {
if (typeof process === 'object') { //node environment
if (!isBrowser) { //node environment
return toArrayBuffer(Buffer.isBuffer(file) ? file : file.buffer || file);
}

Expand Down
1 change: 1 addition & 0 deletions src/parsers/utils/isBrowser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default typeof window !== 'undefined' && typeof window.document !== 'undefined';

0 comments on commit 51e1e9d

Please sign in to comment.