@php-wasm/util
Advanced tools
Comparing version
79
index.js
@@ -1,5 +0,5 @@ | ||
const f = Symbol("SleepFinished"); | ||
const h = Symbol("SleepFinished"); | ||
function a(e) { | ||
return new Promise((t) => { | ||
setTimeout(() => t(f), e); | ||
setTimeout(() => t(h), e); | ||
}); | ||
@@ -12,3 +12,3 @@ } | ||
} | ||
class _ { | ||
class x { | ||
constructor({ concurrency: t, timeout: s }) { | ||
@@ -31,3 +31,3 @@ this._running = 0, this.concurrency = t, this.timeout = s, this.queue = []; | ||
(s) => { | ||
if (s === f) | ||
if (s === h) | ||
throw new d(); | ||
@@ -53,3 +53,3 @@ } | ||
} | ||
class x extends Error { | ||
class S extends Error { | ||
constructor(t, s) { | ||
@@ -65,8 +65,8 @@ super(t), this.userFriendlyMessage = s ?? t; | ||
const i = s[0] === "/", n = t(s); | ||
return s = c(s), !s && !i && (s = "."), s && n && !t(s) && (s += "/"), s; | ||
return s = l(s), !s && !i && (s = "."), s && n && !t(s) && (s += "/"), s; | ||
} | ||
function S(e) { | ||
function U(e) { | ||
if (e === "/") | ||
return "/"; | ||
e = c(e); | ||
e = l(e); | ||
const t = e.lastIndexOf("/"); | ||
@@ -78,7 +78,7 @@ return t === -1 ? "" : t === 0 ? "/" : e.substr(0, t); | ||
return "/"; | ||
e = c(e); | ||
e = l(e); | ||
const t = e.lastIndexOf("/"); | ||
return t === -1 ? e : e.substr(t + 1); | ||
} | ||
function c(e) { | ||
function l(e) { | ||
const t = e[0] === "/"; | ||
@@ -101,4 +101,4 @@ return e = g( | ||
} | ||
function U(e, t) { | ||
return e === "/" ? !0 : (e = c(e), t = c(t), t.startsWith(e + "/") || t === e); | ||
function A(e, t) { | ||
return e === "/" ? !0 : (e = l(e), t = l(t), t.startsWith(e + "/") || t === e); | ||
} | ||
@@ -110,4 +110,4 @@ function m(e) { | ||
for (let o = 0; o < e.length; o++) { | ||
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); | ||
const c = e[o]; | ||
c === "\\" ? ((e[o + 1] === '"' || e[o + 1] === "'") && o++, r += e[o]) : i === 0 ? c === '"' || c === "'" ? (i = 1, n = c) : c.match(/\s/) ? (r.trim().length && u.push(r.trim()), r = c) : u.length && !r ? r = u.pop() + c : r += c : i === 1 && (c === n ? (i = 0, n = "") : r += c); | ||
} | ||
@@ -138,3 +138,3 @@ return r && u.push(r.trim()), u; | ||
} | ||
class h { | ||
class f { | ||
constructor() { | ||
@@ -152,3 +152,3 @@ this.listeners = {}; | ||
} | ||
class E extends h { | ||
class E extends f { | ||
constructor(t) { | ||
@@ -171,2 +171,5 @@ super(), this.exited = !1, this.stdinData = [], this.childProcess = t, t.on("stdin", (s) => { | ||
} | ||
notifySpawn() { | ||
this.childProcess.emit("spawn", !0); | ||
} | ||
exit(t) { | ||
@@ -183,5 +186,5 @@ this.exited || (this.exited = !0, this.childProcess.emit("exit", t)); | ||
let w = 9743; | ||
class y extends h { | ||
class y extends f { | ||
constructor(t = w++) { | ||
super(), this.stdout = new h(), this.stderr = new h(); | ||
super(), this.stdout = new f(), this.stderr = new f(); | ||
const s = this; | ||
@@ -195,3 +198,3 @@ this.pid = t, this.stdin = { | ||
} | ||
function P(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") { | ||
function p(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") { | ||
const s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + t; | ||
@@ -204,5 +207,5 @@ let i = ""; | ||
function M() { | ||
return P(36, "-_"); | ||
return p(36, "-_"); | ||
} | ||
function p(e) { | ||
function P(e) { | ||
return `json_decode(base64_decode('${D( | ||
@@ -212,6 +215,6 @@ JSON.stringify(e) | ||
} | ||
function A(e) { | ||
function Q(e) { | ||
const t = {}; | ||
for (const s in e) | ||
t[s] = p(e[s]); | ||
t[s] = P(e[s]); | ||
return t; | ||
@@ -226,17 +229,31 @@ } | ||
} | ||
function _(e) { | ||
let t = 0; | ||
e.forEach((n) => t += n.length); | ||
const s = new Uint8Array(t); | ||
let i = 0; | ||
return e.forEach((n) => { | ||
s.set(n, i), i += n.length; | ||
}), s; | ||
} | ||
function I(e) { | ||
return _(e.map((t) => new Uint8Array(t))).buffer; | ||
} | ||
export { | ||
d as AcquireTimeoutError, | ||
x as PhpWasmError, | ||
_ as Semaphore, | ||
S as PhpWasmError, | ||
x as Semaphore, | ||
b as basename, | ||
I as concatArrayBuffers, | ||
_ as concatUint8Arrays, | ||
q as createSpawnHandler, | ||
S as dirname, | ||
U as isParentOf, | ||
U as dirname, | ||
A as isParentOf, | ||
T as joinPaths, | ||
c as normalizePath, | ||
p as phpVar, | ||
A as phpVars, | ||
l as normalizePath, | ||
P as phpVar, | ||
Q as phpVars, | ||
M as randomFilename, | ||
P as randomString | ||
p as randomString | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -35,2 +35,3 @@ type Listener = (...args: any[]) => any; | ||
stderrEnd(): void; | ||
notifySpawn(): void; | ||
exit(code: number): void; | ||
@@ -37,0 +38,0 @@ flushStdin(): void; |
@@ -10,1 +10,3 @@ import Semaphore, { AcquireTimeoutError } from './semaphore'; | ||
export * from './php-vars'; | ||
export declare function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array; | ||
export declare function concatArrayBuffers(buffers: ArrayBuffer[]): ArrayBuffer; |
{ | ||
"name": "@php-wasm/util", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"type": "module", | ||
@@ -26,3 +26,3 @@ "types": "index.d.ts", | ||
"module": "./index.js", | ||
"gitHead": "59c2db1ec41efa10ffa01e6e1ea7ac6e78bc693e", | ||
"gitHead": "977f8e90eabb2c8d4eed75677ddd9fb6c13274ae", | ||
"engines": { | ||
@@ -29,0 +29,0 @@ "node": ">=20.18.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80344
5.27%444
5.21%