diff --git a/source/index.js b/source/index.js index 88c7528..e5a0abe 100644 --- a/source/index.js +++ b/source/index.js @@ -21,6 +21,20 @@ const levelMapping = [ 'ansi16m', ]; +// True for any Browser or WebWorker +// copied from https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js available under the MIT license +const isBrowser = + (typeof window !== "undefined" && typeof window.document !== "undefined") + || + (typeof self === "object" && + self.constructor && + self.constructor.name === "DedicatedWorkerGlobalScope"); + +if(isBrowser) +{ + stderrColor = stdoutColor = 3; +} + const styles = Object.create(null); const applyOptions = (object, options = {}) => {