content-entry-transform 1.2.0 → 1.3.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/README.md +33 -0
- package/package.json +3 -2
- package/src/expression-transformer.mjs +8 -3
- package/src/matcher.mjs +5 -4
- package/src/transform.mjs +1 -0
package/README.md
CHANGED
|
@@ -10,10 +10,43 @@
|
|
|
10
10
|
[](https://coveralls.io/github/arlac77/content-entry-transform)
|
|
11
11
|
|
|
12
12
|
# content-entry-transform
|
|
13
|
+
|
|
13
14
|
transform content entries
|
|
14
15
|
|
|
15
16
|
# API
|
|
16
17
|
|
|
18
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
19
|
+
|
|
20
|
+
### Table of Contents
|
|
21
|
+
|
|
22
|
+
* [createPropertiesTransformer](#createpropertiestransformer)
|
|
23
|
+
* [Parameters](#parameters)
|
|
24
|
+
* [transform](#transform)
|
|
25
|
+
* [Parameters](#parameters-1)
|
|
26
|
+
|
|
27
|
+
## createPropertiesTransformer
|
|
28
|
+
|
|
29
|
+
Creates a new transformer.
|
|
30
|
+
On match the enrtry will be assigned noe properties as given by propertyDefinitions.
|
|
31
|
+
|
|
32
|
+
### Parameters
|
|
33
|
+
|
|
34
|
+
* `match`
|
|
35
|
+
* `propertyDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
36
|
+
* `name` (optional, default `"property"`)
|
|
37
|
+
* `matcher` **Matcher**
|
|
38
|
+
|
|
39
|
+
Returns **Transformer**
|
|
40
|
+
|
|
41
|
+
## transform
|
|
42
|
+
|
|
43
|
+
Apply transformers.
|
|
44
|
+
|
|
45
|
+
### Parameters
|
|
46
|
+
|
|
47
|
+
* `source` **AsyncIterator\<ContentEntry>**
|
|
48
|
+
* `transformers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Transformer>** (optional, default `[]`)
|
|
49
|
+
* `onlyMatching`
|
|
17
50
|
|
|
18
51
|
# install
|
|
19
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "content-entry-transform",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"content-entry": "^4.
|
|
28
|
+
"content-entry": "^4.1.0",
|
|
29
|
+
"iterable-string-interceptor": "^1.0.11"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"ava": "^4.0.1",
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { ReadableStreamContentEntry } from "content-entry";
|
|
2
|
+
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
3
|
+
|
|
4
|
+
export const utf8StreamOptions = { encoding: "utf8" };
|
|
5
|
+
|
|
1
6
|
export function createPropertiesInterceptor(properties) {
|
|
2
7
|
return async function* transformer(expression, remainder, source, cb) {
|
|
3
8
|
const value = properties[expression];
|
|
@@ -6,12 +11,12 @@ export function createPropertiesInterceptor(properties) {
|
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
export function createExpressionTransformer(
|
|
14
|
+
match,
|
|
9
15
|
properties,
|
|
10
|
-
|
|
11
|
-
entry.name.match(/\.(conf|json|html|txt|service|socket)$/) ? true : false
|
|
16
|
+
name = "expression"
|
|
12
17
|
) {
|
|
13
18
|
return {
|
|
14
|
-
name
|
|
19
|
+
name,
|
|
15
20
|
match,
|
|
16
21
|
transform: async entry => {
|
|
17
22
|
//console.log("TRANSFORM",entry.name);
|
package/src/matcher.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function nameExtensionMatcher(extensions)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export function nameExtensionMatcher(extensions) {
|
|
2
|
+
const r = new RegExp(
|
|
3
|
+
`(${extensions.map(x => x.replace(/\./, "\\.")).join("|")})$`
|
|
4
|
+
);
|
|
5
|
+
return entry => r.test(entry.name);
|
|
5
6
|
}
|