From 3f2a51904b5b5b2ccea71d31cf02c929a820434c Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 12 Feb 2026 19:10:05 +0200 Subject: [PATCH] Initial commit --- index.html | 318 ++++++ lzma.js | 153 +++ lzma_worker.js | 2668 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 3139 insertions(+) create mode 100644 index.html create mode 100644 lzma.js create mode 100644 lzma_worker.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..682db03 --- /dev/null +++ b/index.html @@ -0,0 +1,318 @@ + + + + +Paste + + + + +
+
1
+ +
+ + + + diff --git a/lzma.js b/lzma.js new file mode 100644 index 0000000..9a61bef --- /dev/null +++ b/lzma.js @@ -0,0 +1,153 @@ +//! © 2015 Nathan Rugg | MIT +/// See LICENSE for more details. + +// jshint bitwise:true, curly:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, noempty:true, nonew:true, onevar:true, plusplus:true, quotmark:double, undef:true, unused:strict, browser: true, node: true + +/// Does the environment support web workers? If not, let's load the worker manually (without polluting the global scope). +if (typeof Worker === "undefined" || (typeof location !== "undefined" && location.protocol === "file:")) { + /// Is this Node.js? + if (typeof global !== "undefined" && typeof require !== "undefined") { + this.LZMA = function (lzma_path) { + return require(lzma_path || "./lzma_worker.js").LZMA; + }; + /// Is this a browser? + } else if (typeof window !== "undefined" && window.document) { + (function () { + var that = this, + global_var, + req = function req(path) { + var script_tag = document.createElement("script"); + script_tag.type ="text/javascript"; + script_tag.src = path; + script_tag.onload = function () { + /// Make sure this LZMA variable doesn't get overwritten by the worker's. + that.LZMA = non_worker_lzma; + }; + document.getElementsByTagName("head")[0].appendChild(script_tag); + }; + + /// Determine the global variable (it's called "window" in browsers, "global" in Node.js). + if (typeof window !== "undefined") { + global_var = window; + } else if (global) { + global_var = global; + } + + function non_worker_lzma(path) { + var fake_lzma; + + req(path); + + fake_lzma = { + compress: function compress(mixed, mode, on_finish, on_progress) { + if (global_var.LZMA_WORKER) { + global_var.LZMA_WORKER.compress(mixed, mode, on_finish, on_progress); + } else { + /// Wait + setTimeout(function () + { + fake_lzma.compress(mixed, mode, on_finish, on_progress); + }, 50); + } + }, + decompress: function decompress(byte_arr, on_finish, on_progress) { + if (global_var.LZMA_WORKER) { + global_var.LZMA_WORKER.decompress(byte_arr, on_finish, on_progress); + } else { + /// Wait + setTimeout(function () + { + fake_lzma.decompress(byte_arr, on_finish, on_progress); + }, 50); + } + }, + worker: function worker () { + return null; + } + }; + + return fake_lzma; + } + + that.LZMA = non_worker_lzma; + }()); + } else { + /// It doesn't seem to be either Node.js or a browser. + console.error("Can't load the worker. Sorry."); + } +} else { + /// Let's use Web Workers. + ///NOTE: The "this" keyword is the global context ("window" variable) if loaded via a