@php-wasm/node-polyfills
Advanced tools
Comparing version 1.0.11 to 1.0.12
55
index.js
@@ -1,4 +0,4 @@ | ||
const u = function() { | ||
var o; | ||
return typeof process < "u" && ((o = process.release) == null ? void 0 : o.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : ( | ||
const f = function() { | ||
var n; | ||
return typeof process < "u" && ((n = process.release) == null ? void 0 : n.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : ( | ||
// @ts-ignore | ||
@@ -9,13 +9,13 @@ typeof WorkerGlobalScope < "u" && // @ts-ignore | ||
}(); | ||
if (u === "NODE") { | ||
let o = function(e) { | ||
return new Promise(function(t, n) { | ||
if (f === "NODE") { | ||
let n = function(e) { | ||
return new Promise(function(t, r) { | ||
e.onload = e.onerror = function(i) { | ||
e.onload = e.onerror = null, i.type === "load" ? t(e.result) : n(new Error("Failed to read the blob/file")); | ||
e.onload = e.onerror = null, i.type === "load" ? t(e.result) : r(new Error("Failed to read the blob/file")); | ||
}; | ||
}); | ||
}, a = function() { | ||
const e = new Uint8Array([1, 2, 3, 4]), n = new File([e], "test").stream(); | ||
const e = new Uint8Array([1, 2, 3, 4]), r = new File([e], "test").stream(); | ||
try { | ||
return n.getReader({ mode: "byob" }), !0; | ||
return r.getReader({ mode: "byob" }), !0; | ||
} catch { | ||
@@ -27,6 +27,6 @@ return !1; | ||
class e extends Blob { | ||
constructor(n, i, s) { | ||
super(n); | ||
let r; | ||
s != null && s.lastModified && (r = /* @__PURE__ */ new Date()), (!r || isNaN(r.getFullYear())) && (r = /* @__PURE__ */ new Date()), this.lastModifiedDate = r, this.lastModified = r.getMilliseconds(), this.name = i || ""; | ||
constructor(r, i, s) { | ||
super(r); | ||
let o; | ||
s != null && s.lastModified && (o = /* @__PURE__ */ new Date()), (!o || isNaN(o.getFullYear())) && (o = /* @__PURE__ */ new Date()), this.lastModifiedDate = o, this.lastModified = o.getMilliseconds(), this.name = i || ""; | ||
} | ||
@@ -38,6 +38,6 @@ } | ||
const t = new FileReader(); | ||
return t.readAsArrayBuffer(this), o(t); | ||
return t.readAsArrayBuffer(this), n(t); | ||
}), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() { | ||
const t = new FileReader(); | ||
return t.readAsText(this), o(t); | ||
return t.readAsText(this), n(t); | ||
}), (typeof Blob.prototype.stream > "u" || !a()) && (Blob.prototype.stream = function() { | ||
@@ -51,10 +51,10 @@ let e = 0; | ||
autoAllocateChunkSize: 512 * 1024, | ||
async pull(n) { | ||
const i = n.byobRequest.view, r = await t.slice( | ||
async pull(r) { | ||
const i = r.byobRequest.view, o = await t.slice( | ||
e, | ||
e + i.byteLength | ||
).arrayBuffer(), f = new Uint8Array(r); | ||
new Uint8Array(i.buffer).set(f); | ||
const l = f.byteLength; | ||
n.byobRequest.respond(l), e += l, e >= t.size && n.close(); | ||
).arrayBuffer(), u = new Uint8Array(o); | ||
new Uint8Array(i.buffer).set(u); | ||
const l = u.byteLength; | ||
r.byobRequest.respond(l), e += l, e >= t.size && r.close(); | ||
} | ||
@@ -64,4 +64,4 @@ }); | ||
} | ||
if (u === "NODE" && typeof CustomEvent > "u") { | ||
class o extends Event { | ||
if (f === "NODE" && typeof CustomEvent > "u") { | ||
class n extends Event { | ||
constructor(e, t = {}) { | ||
@@ -73,3 +73,10 @@ super(e, t), this.detail = t.detail; | ||
} | ||
globalThis.CustomEvent = o; | ||
globalThis.CustomEvent = n; | ||
} | ||
f === "NODE" && typeof URL.canParse != "function" && (globalThis.URL.canParse = function(n) { | ||
try { | ||
return !!new URL(n); | ||
} catch { | ||
return !1; | ||
} | ||
}); |
{ | ||
"name": "@php-wasm/node-polyfills", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "PHP.wasm – polyfills for Node.js", | ||
@@ -34,4 +34,4 @@ "repository": { | ||
"license": "GPL-2.0-or-later", | ||
"gitHead": "930fa61fa8b834fd4cb4e1c83954e6f3d173ed09", | ||
"gitHead": "e5cb134823eedc139ca490661b75d490364cc0b7", | ||
"dependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23763
10
88