@php-wasm/util
Advanced tools
Comparing version 0.9.20 to 0.9.21
67
index.js
const f = Symbol("SleepFinished"); | ||
function d(e) { | ||
function a(e) { | ||
return new Promise((t) => { | ||
@@ -7,3 +7,3 @@ setTimeout(() => t(f), e); | ||
} | ||
class a extends Error { | ||
class d extends Error { | ||
constructor() { | ||
@@ -29,6 +29,6 @@ super("Acquiring lock timed out"); | ||
}); | ||
this.timeout !== void 0 ? await Promise.race([t, d(this.timeout)]).then( | ||
this.timeout !== void 0 ? await Promise.race([t, a(this.timeout)]).then( | ||
(s) => { | ||
if (s === f) | ||
throw new a(); | ||
throw new d(); | ||
} | ||
@@ -59,5 +59,8 @@ ) : await t; | ||
function T(...e) { | ||
let t = e.join("/"); | ||
const s = t[0] === "/", i = t.substring(t.length - 1) === "/"; | ||
return t = c(t), !t && !s && (t = "."), t && i && (t += "/"), t; | ||
function t(u) { | ||
return u.substring(u.length - 1) === "/"; | ||
} | ||
let s = e.join("/"); | ||
const i = s[0] === "/", n = t(s); | ||
return s = c(s), !s && !i && (s = "."), s && n && !t(s) && (s += "/"), s; | ||
} | ||
@@ -88,4 +91,4 @@ function S(e) { | ||
for (let i = e.length - 1; i >= 0; i--) { | ||
const r = e[i]; | ||
r === "." ? e.splice(i, 1) : r === ".." ? (e.splice(i, 1), s++) : s && (e.splice(i, 1), s--); | ||
const n = e[i]; | ||
n === "." ? e.splice(i, 1) : n === ".." ? (e.splice(i, 1), s++) : s && (e.splice(i, 1), s--); | ||
} | ||
@@ -101,31 +104,31 @@ if (t) | ||
function m(e) { | ||
let i = 0, r = ""; | ||
const l = []; | ||
let n = ""; | ||
let i = 0, n = ""; | ||
const u = []; | ||
let r = ""; | ||
for (let o = 0; o < e.length; o++) { | ||
const u = e[o]; | ||
u === "\\" ? ((e[o + 1] === '"' || e[o + 1] === "'") && o++, n += e[o]) : i === 0 ? u === '"' || u === "'" ? (i = 1, r = u) : u.match(/\s/) ? (n.trim().length && l.push(n.trim()), n = u) : l.length && !n ? n = l.pop() + u : n += u : i === 1 && (u === r ? (i = 0, r = "") : n += u); | ||
const l = e[o]; | ||
l === "\\" ? ((e[o + 1] === '"' || e[o + 1] === "'") && o++, r += e[o]) : i === 0 ? l === '"' || l === "'" ? (i = 1, n = l) : l.match(/\s/) ? (r.trim().length && u.push(r.trim()), r = l) : u.length && !r ? r = u.pop() + l : r += l : i === 1 && (l === n ? (i = 0, n = "") : r += l); | ||
} | ||
return n && l.push(n.trim()), l; | ||
return r && u.push(r.trim()), u; | ||
} | ||
function U(e) { | ||
return function(t, s = [], i = {}) { | ||
const r = new w(), l = new E(r); | ||
const n = new w(), u = new E(n); | ||
return setTimeout(async () => { | ||
let n = []; | ||
let r = []; | ||
if (s.length) | ||
n = [t, ...s]; | ||
r = [t, ...s]; | ||
else if (typeof t == "string") | ||
n = m(t); | ||
r = m(t); | ||
else if (Array.isArray(t)) | ||
n = t; | ||
r = t; | ||
else | ||
throw new Error("Invalid command ", t); | ||
try { | ||
await e(n, l, i); | ||
await e(r, u, i); | ||
} catch (o) { | ||
r.emit("error", o), typeof o == "object" && o !== null && "message" in o && typeof o.message == "string" && l.stderr(o.message), l.exit(1); | ||
n.emit("error", o), typeof o == "object" && o !== null && "message" in o && typeof o.message == "string" && u.stderr(o.message), u.exit(1); | ||
} | ||
r.emit("spawn", !0); | ||
}), r; | ||
n.emit("spawn", !0); | ||
}), n; | ||
}; | ||
@@ -186,6 +189,6 @@ } | ||
} | ||
function p(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") { | ||
function P(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") { | ||
const s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + t; | ||
let i = ""; | ||
for (let r = e; r > 0; --r) | ||
for (let n = e; n > 0; --n) | ||
i += s[Math.floor(Math.random() * s.length)]; | ||
@@ -195,5 +198,5 @@ return i; | ||
function q() { | ||
return p(36, "-_"); | ||
return P(36, "-_"); | ||
} | ||
function P(e) { | ||
function p(e) { | ||
return `json_decode(base64_decode('${D( | ||
@@ -206,3 +209,3 @@ JSON.stringify(e) | ||
for (const s in e) | ||
t[s] = P(e[s]); | ||
t[s] = p(e[s]); | ||
return t; | ||
@@ -218,3 +221,3 @@ } | ||
export { | ||
a as AcquireTimeoutError, | ||
d as AcquireTimeoutError, | ||
x as PhpWasmError, | ||
@@ -228,6 +231,6 @@ _ as Semaphore, | ||
c as normalizePath, | ||
P as phpVar, | ||
p as phpVar, | ||
A as phpVars, | ||
q as randomFilename, | ||
p as randomString | ||
P as randomString | ||
}; |
{ | ||
"name": "@php-wasm/util", | ||
"version": "0.9.20", | ||
"version": "0.9.21", | ||
"type": "module", | ||
@@ -16,3 +16,3 @@ "types": "index.d.ts", | ||
}, | ||
"gitHead": "f619fcb719128d247bec296b9339aff52101e948", | ||
"gitHead": "a497916495035caba2f28cfdef75a8a0f3732f0e", | ||
"engines": { | ||
@@ -19,0 +19,0 @@ "node": ">=18.18.0", |
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
28771
243