@php-wasm/util 0.1.61 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +40 -0
- package/package.json +6 -2
package/index.js
CHANGED
|
@@ -40,6 +40,45 @@ var Semaphore = class {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
// packages/php-wasm/util/src/lib/join-paths.ts
|
|
44
|
+
function joinPaths(...paths) {
|
|
45
|
+
let path = paths.join("/");
|
|
46
|
+
const isAbsolute = path.charAt(0) === "/";
|
|
47
|
+
const trailingSlash = path.substring(path.length - 1) === "/";
|
|
48
|
+
path = normalizePathsArray(
|
|
49
|
+
path.split("/").filter((p) => !!p),
|
|
50
|
+
!isAbsolute
|
|
51
|
+
).join("/");
|
|
52
|
+
if (!path && !isAbsolute) {
|
|
53
|
+
path = ".";
|
|
54
|
+
}
|
|
55
|
+
if (path && trailingSlash) {
|
|
56
|
+
path += "/";
|
|
57
|
+
}
|
|
58
|
+
return (isAbsolute ? "/" : "") + path;
|
|
59
|
+
}
|
|
60
|
+
function normalizePathsArray(parts, allowAboveRoot) {
|
|
61
|
+
let up = 0;
|
|
62
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
63
|
+
const last = parts[i];
|
|
64
|
+
if (last === ".") {
|
|
65
|
+
parts.splice(i, 1);
|
|
66
|
+
} else if (last === "..") {
|
|
67
|
+
parts.splice(i, 1);
|
|
68
|
+
up++;
|
|
69
|
+
} else if (up) {
|
|
70
|
+
parts.splice(i, 1);
|
|
71
|
+
up--;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (allowAboveRoot) {
|
|
75
|
+
for (; up; up--) {
|
|
76
|
+
parts.unshift("..");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return parts;
|
|
80
|
+
}
|
|
81
|
+
|
|
43
82
|
// packages/php-wasm/util/src/lib/php-vars.ts
|
|
44
83
|
var literal = Symbol("literal");
|
|
45
84
|
function phpVar(value) {
|
|
@@ -77,6 +116,7 @@ function phpVars(vars) {
|
|
|
77
116
|
}
|
|
78
117
|
export {
|
|
79
118
|
Semaphore,
|
|
119
|
+
joinPaths,
|
|
80
120
|
phpVar,
|
|
81
121
|
phpVars
|
|
82
122
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/util",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"typedoc": {
|
|
6
6
|
"entryPoint": "./src/index.ts",
|
|
@@ -12,5 +12,9 @@
|
|
|
12
12
|
"access": "public",
|
|
13
13
|
"directory": "../../../dist/packages/php-wasm/util"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "cd4062de74f7f18058d3f962e124d0fdff78b5a7",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16.15.1",
|
|
18
|
+
"npm": ">=8.11.0"
|
|
19
|
+
}
|
|
16
20
|
}
|