iterable-string-interceptor 1.0.11 → 1.0.12
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 +1 -1
- package/README.md +8 -6
- package/package.json +5 -5
- package/src/iterable-string-interceptor.mjs +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,11 +18,12 @@ Intercept Iterable string - backbone for templates
|
|
|
18
18
|
```javascript
|
|
19
19
|
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
20
20
|
import { createReadStream } from "fs";
|
|
21
|
+
import { readFile } from "fs/promises";
|
|
21
22
|
|
|
22
23
|
// double values inside {{}}
|
|
23
24
|
// {{7}} -> 14
|
|
24
25
|
for await (const chunk of iterableStringInterceptor(createReadStream('aFile', { encoding: "utf8" }),
|
|
25
|
-
|
|
26
|
+
expression => expression * 2
|
|
26
27
|
)) {
|
|
27
28
|
process.stdout.write(chunk);
|
|
28
29
|
}
|
|
@@ -30,11 +31,12 @@ async * (expression) => { yield expression * 2; }
|
|
|
30
31
|
|
|
31
32
|
```javascript
|
|
32
33
|
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
33
|
-
import
|
|
34
|
+
import { createReadStream } from "fs";
|
|
35
|
+
import { readFile } from "fs/promises";
|
|
34
36
|
|
|
35
37
|
// handle expression as to be included content {{filename}}
|
|
36
38
|
for await (const chunk of iterableStringInterceptor(createReadStream('aFile', { encoding: "utf8" }),
|
|
37
|
-
async * (expression) => { yield
|
|
39
|
+
async * (expression) => { yield readFile(expression, { encoding: "utf8" }); }
|
|
38
40
|
)) {
|
|
39
41
|
process.stdout.write(chunk);
|
|
40
42
|
}
|
|
@@ -70,7 +72,7 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
|
|
|
70
72
|
|
|
71
73
|
## EarlyConsumerCallback
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
74
76
|
|
|
75
77
|
Type: ()
|
|
76
78
|
|
|
@@ -80,8 +82,8 @@ Type: ()
|
|
|
80
82
|
|
|
81
83
|
## iterableStringInterceptor
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
and asking a transformer for a replacement iterable string
|
|
85
|
+
Intercept into a async iterable string source, detecting lead in/outs like '{{' and '}}'
|
|
86
|
+
and asking a transformer for a replacement iterable string.
|
|
85
87
|
|
|
86
88
|
### Parameters
|
|
87
89
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-string-interceptor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "^
|
|
33
|
-
"c8": "^7.
|
|
32
|
+
"ava": "^4.0.1",
|
|
33
|
+
"c8": "^7.11.0",
|
|
34
34
|
"documentation": "^13.2.5",
|
|
35
|
-
"semantic-release": "^
|
|
35
|
+
"semantic-release": "^19.0.2"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=14.
|
|
38
|
+
"node": ">=14.18.3"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
14
14
|
* @typedef {()} EarlyConsumerCallback
|
|
15
15
|
* @param {string} remainder new remainder to be used by iterableStringInterceptor
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* and asking a transformer for a replacement iterable string
|
|
19
|
+
* Intercept into a async iterable string source, detecting lead in/outs like '{{' and '}}'
|
|
20
|
+
* and asking a transformer for a replacement iterable string.
|
|
21
21
|
* @param {Iterable<string>} source
|
|
22
22
|
* @param {ExpressionTransformer} transform
|
|
23
23
|
* @param {string} leadIn expression entry sequence
|