content-entry-transform 1.3.18 → 1.4.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/README.md CHANGED
@@ -27,7 +27,7 @@ transform content entries
27
27
  ## createPropertiesTransformer
28
28
 
29
29
  Creates a new transformer.
30
- On match the enrtry will be assigned new properties as given by propertyDefinitions.
30
+ On match the entry will be assigned new properties as given by propertyDefinitions.
31
31
 
32
32
  ### Parameters
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "content-entry-transform",
3
- "version": "1.3.18",
3
+ "version": "1.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,12 +25,12 @@
25
25
  "lint:docs": "documentation lint ./src/**/*.mjs"
26
26
  },
27
27
  "dependencies": {
28
- "content-entry": "^4.1.11",
28
+ "content-entry": "^5.0.1",
29
29
  "iterable-string-interceptor": "^2.0.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "ava": "^4.2.0",
33
- "c8": "^7.11.0",
33
+ "c8": "^7.11.3",
34
34
  "documentation": "^13.2.5",
35
35
  "semantic-release": "^19.0.2"
36
36
  },
@@ -4,9 +4,31 @@ 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(expression, remainder, source, cb) {
8
- const value = properties[expression];
9
- yield value === undefined ? "" : value;
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) throw new Error(`Probably circular reference evaluating: ${expression}`);
17
+ const value = properties[e];
18
+ if (value !== undefined) {
19
+ if (typeof value === "string") {
20
+ const li = value.indexOf(leadIn);
21
+ if (li >= 0) {
22
+ const lo = value.indexOf(leadOut, li + leadIn.length);
23
+ return ev(value.substring(li + leadIn.length, lo), deepth + 1);
24
+ }
25
+ }
26
+ return value;
27
+ }
28
+ return "";
29
+ }
30
+
31
+ yield ev(expression, 0);
10
32
  };
11
33
  }
12
34
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Creates a new transformer.
3
- * On match the enrtry will be assigned new properties as given by propertyDefinitions.
3
+ * On match the entry will be assigned new properties as given by propertyDefinitions.
4
4
  * @param {Object} propertyDefinitions
5
5
  * @param {Matcher} matcher
6
6
  * @return {Transformer}