From 8ed01d82b733b8255cfb3c09baec43e64682b21b Mon Sep 17 00:00:00 2001 From: Marc Robledo Date: Sat, 12 Apr 2025 21:11:37 +0200 Subject: [PATCH] fix for Web Worker fixes issues #12 and #35 --- msgpack.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/msgpack.js b/msgpack.js index cd4e505..33b9663 100644 --- a/msgpack.js +++ b/msgpack.js @@ -547,8 +547,12 @@ // Node.js module.exports = msgpack; } - else { - // Global object + else if (typeof WorkerGlobalScope === "function" && self instanceof WorkerGlobalScope) { + // Web Worker scope + self.msgpack = msgpack; + } + else if (typeof window === "object") { + // Web browser window[window.msgpackJsName || "msgpack"] = msgpack; }