-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththread.min.js
1 lines (1 loc) · 1.71 KB
/
thread.min.js
1
(function (c, d, f, b) { var a = function (j) { var i = function (k) { var l = function () { this.result = null; this.error = null; this.postMessage = function (m) { try { this.result = k(m); } catch (n) { this.error = n; } }; this.close = function () { this.result = null; this.error = null; }; }; return new l(j); }, g = function (l) { var p = function (r) { var q, s; try { q = new f([r], { type: "text/javascript" }); } catch (t) { s = c.BlobBuilder || c.WebKitBlobBuilder || c.MozBlobBuilder; q = new s(); q.append(r); q = q.getBlob(); } return q; }, k = "onmessage = function (msg) { var job = " + l.toString() + "; var result = job(msg.data); this.postMessage(result); };", m = p(k), n = b.createObjectURL(m), o = new d(n); o.close = function () { this.terminate(); if (m && n) { b.revokeObjectURL(n); } }; return o; }, h = function (l) { var k; try { k = (l === false) || !d ? i(j) : g(j); } catch (m) { k = i(j); } return k; }; return { create: h }; }, e = function (j) { var g = this, h = j || {}, i, l, k; this.then = function (m) { if (i.result) { m.bind(this)(i.result); } l = m; return this; }; this.fail = function (m) { if (i.error) { m.bind(this)(i.error); } k = m; return this; }; this.start = function (n, m) { i = a(m).create(h.parallel); i.onmessage = function (o) { if (typeof l === "function") { l.bind(g)(o.data); } }; i.onerror = function (o) { if (typeof k === "function") { k.bind(g)(o); } }; i.postMessage(n); return this; }; this.close = function () { i.close(); }; this.reStart = function (m) { if (i.result) { i.result = null; } if (i.error) { i.error = null; } i.postMessage(m); return this; }; this.id = h.id; }; if (!c.Thread) { c.Thread = e; } return e; }(window, window.Worker, Blob, window.URL || window.webkitURL));