@php-wasm/util
Advanced tools
Comparing version 0.9.15 to 0.9.16
224
index.js
@@ -1,1 +0,223 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=Symbol("SleepFinished");function m(t){return new Promise(e=>{setTimeout(()=>e(f),t)})}class a extends Error{constructor(){super("Acquiring lock timed out")}}class E{constructor({concurrency:e,timeout:s}){this._running=0,this.concurrency=e,this.timeout=s,this.queue=[]}get remaining(){return this.concurrency-this.running}get running(){return this._running}async acquire(){for(;;)if(this._running>=this.concurrency){const e=new Promise(s=>{this.queue.push(s)});this.timeout!==void 0?await Promise.race([e,m(this.timeout)]).then(s=>{if(s===f)throw new a}):await e}else{this._running++;let e=!1;return()=>{e||(e=!0,this._running--,this.queue.length>0&&this.queue.shift()())}}}async run(e){const s=await this.acquire();try{return await e()}finally{s()}}}class p extends Error{constructor(e,s){super(e),this.userFriendlyMessage=s,this.userFriendlyMessage||(this.userFriendlyMessage=e)}}function y(...t){let e=t.join("/");const s=e[0]==="/",i=e.substring(e.length-1)==="/";return e=c(e),!e&&!s&&(e="."),e&&i&&(e+="/"),e}function P(t){if(t==="/")return"/";t=c(t);const e=t.lastIndexOf("/");return e===-1?"":e===0?"/":t.substr(0,e)}function w(t){if(t==="/")return"/";t=c(t);const e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)}function c(t){const e=t[0]==="/";return t=O(t.split("/").filter(s=>!!s),!e).join("/"),(e?"/":"")+t.replace(/\/$/,"")}function O(t,e){let s=0;for(let i=t.length-1;i>=0;i--){const n=t[i];n==="."?t.splice(i,1):n===".."?(t.splice(i,1),s++):s&&(t.splice(i,1),s--)}if(e)for(;s;s--)t.unshift("..");return t}function S(t,e){return t==="/"?!0:(t=c(t),e=c(e),e.startsWith(t+"/")||e===t)}function D(t){let i=0,n="";const l=[];let r="";for(let o=0;o<t.length;o++){const u=t[o];u==="\\"?((t[o+1]==='"'||t[o+1]==="'")&&o++,r+=t[o]):i===0?u==='"'||u==="'"?(i=1,n=u):u.match(/\s/)?(r.trim().length&&l.push(r.trim()),r=u):l.length&&!r?r=l.pop()+u:r+=u:i===1&&(u===n?(i=0,n=""):r+=u)}return r&&l.push(r.trim()),l}function _(t){return function(e,s=[],i={}){const n=new x,l=new T(n);return setTimeout(async()=>{let r=[];if(s.length)r=[e,...s];else if(typeof e=="string")r=D(e);else if(Array.isArray(e))r=e;else throw new Error("Invalid command ",e);try{await t(r,l,i)}catch(o){n.emit("error",o),typeof o=="object"&&o!==null&&"message"in o&&typeof o.message=="string"&&l.stderr(o.message),l.exit(1)}n.emit("spawn",!0)}),n}}class h{constructor(){this.listeners={}}emit(e,s){this.listeners[e]&&this.listeners[e].forEach(function(i){i(s)})}on(e,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(s)}}class T extends h{constructor(e){super(),this.childProcess=e,this.exited=!1,this.stdinData=[],e.on("stdin",s=>{this.stdinData?this.stdinData.push(s.slice()):this.emit("stdin",s)})}stdout(e){typeof e=="string"&&(e=new TextEncoder().encode(e)),this.childProcess.stdout.emit("data",e)}stdoutEnd(){this.childProcess.stdout.emit("end",{})}stderr(e){typeof e=="string"&&(e=new TextEncoder().encode(e)),this.childProcess.stderr.emit("data",e)}stderrEnd(){this.childProcess.stderr.emit("end",{})}exit(e){this.exited||(this.exited=!0,this.childProcess.emit("exit",e))}flushStdin(){if(this.stdinData)for(let e=0;e<this.stdinData.length;e++)this.emit("stdin",this.stdinData[e]);this.stdinData=null}}let b=9743;class x extends h{constructor(e=b++){super(),this.pid=e,this.stdout=new h,this.stderr=new h;const s=this;this.stdin={write:i=>{s.emit("stdin",i)}}}}function d(t=36,e="!@#$%^&*()_+=-[]/.,<>?"){const s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+e;let i="";for(let n=t;n>0;--n)i+=s[Math.floor(Math.random()*s.length)];return i}function M(){return d(36,"-_")}function g(t){return`json_decode(base64_decode('${U(JSON.stringify(t))}'), true)`}function q(t){const e={};for(const s in t)e[s]=g(t[s]);return e}function U(t){return A(new TextEncoder().encode(t))}function A(t){const e=String.fromCodePoint(...t);return btoa(e)}exports.AcquireTimeoutError=a;exports.PhpWasmError=p;exports.Semaphore=E;exports.basename=w;exports.createSpawnHandler=_;exports.dirname=P;exports.isParentOf=S;exports.joinPaths=y;exports.normalizePath=c;exports.phpVar=g;exports.phpVars=q;exports.randomFilename=M;exports.randomString=d; | ||
const f = Symbol("SleepFinished"); | ||
function d(e) { | ||
return new Promise((t) => { | ||
setTimeout(() => t(f), e); | ||
}); | ||
} | ||
class a extends Error { | ||
constructor() { | ||
super("Acquiring lock timed out"); | ||
} | ||
} | ||
class _ { | ||
constructor({ concurrency: t, timeout: s }) { | ||
this._running = 0, this.concurrency = t, this.timeout = s, this.queue = []; | ||
} | ||
get remaining() { | ||
return this.concurrency - this.running; | ||
} | ||
get running() { | ||
return this._running; | ||
} | ||
async acquire() { | ||
for (; ; ) | ||
if (this._running >= this.concurrency) { | ||
const t = new Promise((s) => { | ||
this.queue.push(s); | ||
}); | ||
this.timeout !== void 0 ? await Promise.race([t, d(this.timeout)]).then( | ||
(s) => { | ||
if (s === f) | ||
throw new a(); | ||
} | ||
) : await t; | ||
} else { | ||
this._running++; | ||
let t = !1; | ||
return () => { | ||
t || (t = !0, this._running--, this.queue.length > 0 && this.queue.shift()()); | ||
}; | ||
} | ||
} | ||
async run(t) { | ||
const s = await this.acquire(); | ||
try { | ||
return await t(); | ||
} finally { | ||
s(); | ||
} | ||
} | ||
} | ||
class x extends Error { | ||
constructor(t, s) { | ||
super(t), this.userFriendlyMessage = s, this.userFriendlyMessage || (this.userFriendlyMessage = 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 S(e) { | ||
if (e === "/") | ||
return "/"; | ||
e = c(e); | ||
const t = e.lastIndexOf("/"); | ||
return t === -1 ? "" : t === 0 ? "/" : e.substr(0, t); | ||
} | ||
function b(e) { | ||
if (e === "/") | ||
return "/"; | ||
e = c(e); | ||
const t = e.lastIndexOf("/"); | ||
return t === -1 ? e : e.substr(t + 1); | ||
} | ||
function c(e) { | ||
const t = e[0] === "/"; | ||
return e = g( | ||
e.split("/").filter((s) => !!s), | ||
!t | ||
).join("/"), (t ? "/" : "") + e.replace(/\/$/, ""); | ||
} | ||
function g(e, t) { | ||
let s = 0; | ||
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--); | ||
} | ||
if (t) | ||
for (; s; s--) | ||
e.unshift(".."); | ||
return e; | ||
} | ||
function M(e, t) { | ||
return e === "/" ? !0 : (e = c(e), t = c(t), t.startsWith(e + "/") || t === e); | ||
} | ||
function m(e) { | ||
let i = 0, r = ""; | ||
const l = []; | ||
let n = ""; | ||
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); | ||
} | ||
return n && l.push(n.trim()), l; | ||
} | ||
function U(e) { | ||
return function(t, s = [], i = {}) { | ||
const r = new w(), l = new E(r); | ||
return setTimeout(async () => { | ||
let n = []; | ||
if (s.length) | ||
n = [t, ...s]; | ||
else if (typeof t == "string") | ||
n = m(t); | ||
else if (Array.isArray(t)) | ||
n = t; | ||
else | ||
throw new Error("Invalid command ", t); | ||
try { | ||
await e(n, l, 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); | ||
} | ||
r.emit("spawn", !0); | ||
}), r; | ||
}; | ||
} | ||
class h { | ||
constructor() { | ||
this.listeners = {}; | ||
} | ||
emit(t, s) { | ||
this.listeners[t] && this.listeners[t].forEach(function(i) { | ||
i(s); | ||
}); | ||
} | ||
on(t, s) { | ||
this.listeners[t] || (this.listeners[t] = []), this.listeners[t].push(s); | ||
} | ||
} | ||
class E extends h { | ||
constructor(t) { | ||
super(), this.childProcess = t, this.exited = !1, this.stdinData = [], t.on("stdin", (s) => { | ||
this.stdinData ? this.stdinData.push(s.slice()) : this.emit("stdin", s); | ||
}); | ||
} | ||
stdout(t) { | ||
typeof t == "string" && (t = new TextEncoder().encode(t)), this.childProcess.stdout.emit("data", t); | ||
} | ||
stdoutEnd() { | ||
this.childProcess.stdout.emit("end", {}); | ||
} | ||
stderr(t) { | ||
typeof t == "string" && (t = new TextEncoder().encode(t)), this.childProcess.stderr.emit("data", t); | ||
} | ||
stderrEnd() { | ||
this.childProcess.stderr.emit("end", {}); | ||
} | ||
exit(t) { | ||
this.exited || (this.exited = !0, this.childProcess.emit("exit", t)); | ||
} | ||
flushStdin() { | ||
if (this.stdinData) | ||
for (let t = 0; t < this.stdinData.length; t++) | ||
this.emit("stdin", this.stdinData[t]); | ||
this.stdinData = null; | ||
} | ||
} | ||
let y = 9743; | ||
class w extends h { | ||
constructor(t = y++) { | ||
super(), this.pid = t, this.stdout = new h(), this.stderr = new h(); | ||
const s = this; | ||
this.stdin = { | ||
write: (i) => { | ||
s.emit("stdin", i); | ||
} | ||
}; | ||
} | ||
} | ||
function p(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") { | ||
const s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + t; | ||
let i = ""; | ||
for (let r = e; r > 0; --r) | ||
i += s[Math.floor(Math.random() * s.length)]; | ||
return i; | ||
} | ||
function q() { | ||
return p(36, "-_"); | ||
} | ||
function P(e) { | ||
return `json_decode(base64_decode('${D( | ||
JSON.stringify(e) | ||
)}'), true)`; | ||
} | ||
function A(e) { | ||
const t = {}; | ||
for (const s in e) | ||
t[s] = P(e[s]); | ||
return t; | ||
} | ||
function D(e) { | ||
return O(new TextEncoder().encode(e)); | ||
} | ||
function O(e) { | ||
const t = String.fromCodePoint(...e); | ||
return btoa(t); | ||
} | ||
export { | ||
a as AcquireTimeoutError, | ||
x as PhpWasmError, | ||
_ as Semaphore, | ||
b as basename, | ||
U as createSpawnHandler, | ||
S as dirname, | ||
M as isParentOf, | ||
T as joinPaths, | ||
c as normalizePath, | ||
P as phpVar, | ||
A as phpVars, | ||
q as randomFilename, | ||
p as randomString | ||
}; |
{ | ||
"name": "@php-wasm/util", | ||
"version": "0.9.15", | ||
"type": "commonjs", | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts", | ||
"readmeFile": "./README.md", | ||
"displayName": "@php-wasm/util", | ||
"tsconfig": "./tsconfig.lib.json" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"directory": "../../../dist/packages/php-wasm/util" | ||
}, | ||
"gitHead": "62c0b6769e8922ec6ec1fdb985a69c4e86d070a2", | ||
"engines": { | ||
"node": ">=18.18.0", | ||
"npm": ">=8.11.0" | ||
} | ||
"name": "@php-wasm/util", | ||
"version": "0.9.16", | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts", | ||
"readmeFile": "./README.md", | ||
"displayName": "@php-wasm/util", | ||
"tsconfig": "./tsconfig.lib.json" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"directory": "../../../dist/packages/php-wasm/util" | ||
}, | ||
"gitHead": "47110de9a9efc876f7b432c88d904ef081d1365c", | ||
"engines": { | ||
"node": ">=18.18.0", | ||
"npm": ">=8.11.0" | ||
}, | ||
"dependencies": {}, | ||
"main": "index.js" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
32834
6
384
0
12
Yes
2
70
1