content-entry-transform 1.3.20 → 1.4.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "content-entry-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"content-entry": "^5.0.
|
|
28
|
+
"content-entry": "^5.0.2",
|
|
29
29
|
"iterable-string-interceptor": "^2.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -4,9 +4,39 @@ import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
|
4
4
|
export const utf8StreamOptions = { encoding: "utf8" };
|
|
5
5
|
|
|
6
6
|
export function createPropertiesInterceptor(properties) {
|
|
7
|
-
return async function* transformer(
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return async function* transformer(
|
|
8
|
+
expression,
|
|
9
|
+
remainder,
|
|
10
|
+
source,
|
|
11
|
+
cb,
|
|
12
|
+
leadIn,
|
|
13
|
+
leadOut
|
|
14
|
+
) {
|
|
15
|
+
function ev(e, deepth) {
|
|
16
|
+
if (deepth > 9) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`Probably circular reference evaluating: ${expression}`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
const value = properties[e];
|
|
22
|
+
if (value !== undefined) {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
const li = value.indexOf(leadIn);
|
|
25
|
+
if (li >= 0) {
|
|
26
|
+
const lo = value.indexOf(leadOut, li + leadIn.length);
|
|
27
|
+
return (
|
|
28
|
+
value.substring(0, li) +
|
|
29
|
+
ev(value.substring(li + leadIn.length, lo), deepth + 1) +
|
|
30
|
+
value.substring(lo + leadOut.length)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
yield ev(expression, 0);
|
|
10
40
|
};
|
|
11
41
|
}
|
|
12
42
|
|