content-entry-transform 1.4.29 → 1.4.31

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/LICENSE CHANGED
@@ -1,23 +1,12 @@
1
- Copyright (c) 2022-2023 by arlac77
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ Copyright (C) 2022-2025 by arlac77
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/content-entry-transform.svg)](https://www.npmjs.com/package/content-entry-transform)
2
- [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
- [![Open Bundle](https://bundlejs.com/badge-light.svg)](https://bundlejs.com/?q=content-entry-transform)
2
+ [![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
3
+ [![bundlejs](https://deno.bundlejs.com/?q=content-entry-transform\&badge=detailed)](https://bundlejs.com/?q=content-entry-transform)
4
4
  [![downloads](http://img.shields.io/npm/dm/content-entry-transform.svg?style=flat-square)](https://npmjs.org/package/content-entry-transform)
5
5
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/content-entry-transform.svg?style=flat-square)](https://github.com/arlac77/content-entry-transform/issues)
6
6
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fcontent-entry-transform%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/content-entry-transform/goto)
@@ -19,10 +19,22 @@ transform content entries
19
19
 
20
20
  ### Table of Contents
21
21
 
22
- * [createPropertiesTransformer](#createpropertiestransformer)
22
+ * [createExpressionTransformer](#createexpressiontransformer)
23
23
  * [Parameters](#parameters)
24
- * [transform](#transform)
24
+ * [createPropertiesTransformer](#createpropertiestransformer)
25
25
  * [Parameters](#parameters-1)
26
+ * [transform](#transform)
27
+ * [Parameters](#parameters-2)
28
+
29
+ ## createExpressionTransformer
30
+
31
+ Transformer expanding '{{}}' expressions
32
+
33
+ ### Parameters
34
+
35
+ * `match` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
36
+ * `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
37
+ * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (optional, default `"expression"`)
26
38
 
27
39
  ## createPropertiesTransformer
28
40
 
@@ -33,7 +45,7 @@ On match the entry will be assigned new properties as given by propertyDefinitio
33
45
 
34
46
  * `match`  
35
47
  * `propertyDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
36
- * `name` (optional, default `"property"`)
48
+ * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (optional, default `"property"`)
37
49
  * `matcher` **Matcher** 
38
50
 
39
51
  Returns **Transformer** 
@@ -44,9 +56,9 @@ Apply transformers.
44
56
 
45
57
  ### Parameters
46
58
 
47
- * `source` **AsyncIterator\<ContentEntry>**&#x20;
59
+ * `source` **AsyncIterable\<ContentEntry>**&#x20;
48
60
  * `transformers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Transformer>** (optional, default `[]`)
49
- * `onlyMatching` &#x20;
61
+ * `onlyMatching` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** filter out all none matching entries
50
62
 
51
63
  # install
52
64
 
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "content-entry-transform",
3
- "version": "1.4.29",
3
+ "version": "1.4.31",
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "provenance": true
6
7
  },
7
8
  "exports": {
8
9
  ".": "./src/transform.mjs"
@@ -14,30 +15,30 @@
14
15
  "email": "markus.felten@gmx.de"
15
16
  }
16
17
  ],
17
- "license": "BSD-2-Clause",
18
+ "license": "0BSD",
18
19
  "scripts": {
19
- "test": "npm run test:browser-ava && npm run test:ava",
20
- "test:ava": "ava --timeout 2m tests/*-ava.mjs tests/*-ava-node.mjs",
20
+ "test": "node --run test:browser-ava && node --run test:ava",
21
+ "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
21
22
  "test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
22
- "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 2m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
23
- "docs": "documentation readme --section=API ./src/**/*.mjs",
24
- "lint": "npm run lint:docs",
25
- "lint:docs": "documentation lint ./src/**/*.mjs"
23
+ "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
24
+ "docs": "documentation readme --section=API ./src**/*.mjs",
25
+ "lint": "node --run lint:docs",
26
+ "lint:docs": "documentation lint ./src**/*.mjs"
26
27
  },
27
28
  "dependencies": {
28
- "content-entry": "^6.0.0",
29
- "iterable-string-interceptor": "^2.2.3"
29
+ "content-entry": "^13.0.6",
30
+ "iterable-string-interceptor": "^3.0.0"
30
31
  },
31
32
  "devDependencies": {
32
- "ava": "^5.2.0",
33
- "browser-ava": "^1.3.32",
34
- "c8": "^7.13.0",
35
- "documentation": "^14.0.1",
36
- "semantic-release": "^21.0.0"
33
+ "ava": "^6.3.0",
34
+ "browser-ava": "^2.3.24",
35
+ "c8": "^10.1.3",
36
+ "documentation": "^14.0.3",
37
+ "semantic-release": "^24.2.3"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",
40
- "url": "https://github.com/arlac77/content-entry-transform"
41
+ "url": "git+https://github.com/arlac77/content-entry-transform.git"
41
42
  },
42
43
  "bugs": {
43
44
  "url": "https://github.com/arlac77/content-entry-transform/issues"
@@ -47,7 +48,7 @@
47
48
  "inheritFrom": [
48
49
  "arlac77/template-arlac77-github",
49
50
  "arlac77/template-browser-ava",
50
- "arlac77/template-esm-only"
51
+ "arlac77/template-javascript-component"
51
52
  ]
52
53
  }
53
54
  }
@@ -36,33 +36,51 @@ export function createPropertiesInterceptor(properties) {
36
36
  }
37
37
  return value;
38
38
  }
39
- return "";
39
+ else {
40
+ return leadIn + e + leadOut;
41
+ }
42
+ // return "";
40
43
  }
41
44
 
42
45
  yield ev(expression, 0);
43
46
  };
44
47
  }
45
48
 
49
+ /**
50
+ * Transformer expanding '{{}}' expressions
51
+ * @param {string} match
52
+ * @param {Object} properties
53
+ * @param {string} name
54
+ * @returns
55
+ */
46
56
  export function createExpressionTransformer(
47
57
  match,
48
58
  properties,
49
59
  name = "expression"
50
60
  ) {
61
+
62
+ const decoder = new TextDecoder();
63
+
64
+ async function * streamToText(stream)
65
+ {
66
+ for await (const chunk of stream) {
67
+ yield decoder.decode(chunk);
68
+ }
69
+ }
70
+
51
71
  return {
52
72
  name,
53
73
  match,
54
74
  transform: async entry => {
55
- //console.log("TRANSFORM",entry.name);
56
75
  const ne = new ReadableStreamContentEntry(
57
76
  entry.name,
58
77
  iterableStringInterceptor(
59
- await entry.getReadStream(utf8StreamOptions),
78
+ streamToText(await entry.getReadStream()),
60
79
  createPropertiesInterceptor(properties)
61
80
  )
62
81
  );
63
82
  ne.destination = entry.destination; // TODO all the other attributes ?
64
83
  return ne;
65
- //return Object.assign(entry,ne);
66
84
  }
67
85
  };
68
86
  }
@@ -3,6 +3,7 @@
3
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
+ * @param {string} name
6
7
  * @return {Transformer}
7
8
  */
8
9
  export function createPropertiesTransformer(
package/src/transform.mjs CHANGED
@@ -2,11 +2,13 @@ export * from "./properties-transformer.mjs";
2
2
  export * from "./expression-transformer.mjs";
3
3
  export * from "./matcher.mjs";
4
4
 
5
+ import { ContentEntry } from "content-entry";
6
+
5
7
  /**
6
8
  * Apply transformers.
7
- * @param {AsyncIterator<ContentEntry>} source
9
+ * @param {AsyncIterable<ContentEntry>} source
8
10
  * @param {Transformer[]} transformers
9
- * @param {Boolean]} onlyMatching filter out all none matching entries
11
+ * @param {boolean} onlyMatching filter out all none matching entries
10
12
  */
11
13
  export async function* transform(source, transformers = [], onlyMatching) {
12
14
  const usedTransformers = new Set();