iterable-string-interceptor 2.2.4 → 2.3.1
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 +6 -5
- package/dist/iterable-string-interceptor.d.mts +30 -0
- package/package.json +24 -15
- package/src/iterable-string-interceptor.mjs +4 -4
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/iterable-string-interceptor)
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
|
-
[](https://typescriptlang.org)
|
|
4
|
+
[](https://bundlejs.com/?q=iterable-string-interceptor)
|
|
4
5
|
[](https://npmjs.org/package/iterable-string-interceptor)
|
|
5
6
|
[](https://github.com/arlac77/iterable-string-interceptor/issues)
|
|
6
7
|
[](https://actions-badge.atrox.dev/arlac77/iterable-string-interceptor/goto)
|
|
@@ -57,7 +58,7 @@ for await (const chunk of iterableStringInterceptor(createReadStream('aFile', {
|
|
|
57
58
|
|
|
58
59
|
## ExpressionTransformer
|
|
59
60
|
|
|
60
|
-
Type: ()
|
|
61
|
+
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
61
62
|
|
|
62
63
|
### Parameters
|
|
63
64
|
|
|
@@ -68,13 +69,13 @@ Type: ()
|
|
|
68
69
|
* `leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression entry sequence
|
|
69
70
|
* `leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression exit sequence
|
|
70
71
|
|
|
71
|
-
Returns **
|
|
72
|
+
Returns **AsyncIterator<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** transformed source
|
|
72
73
|
|
|
73
74
|
## EarlyConsumerCallback
|
|
74
75
|
|
|
75
76
|
Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
76
77
|
|
|
77
|
-
Type: ()
|
|
78
|
+
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
78
79
|
|
|
79
80
|
### Parameters
|
|
80
81
|
|
|
@@ -92,7 +93,7 @@ and asking a transformer for a replacement iterable string.
|
|
|
92
93
|
* `leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression entry sequence (optional, default `"{{"`)
|
|
93
94
|
* `leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression exit sequence (optional, default `"}}"`)
|
|
94
95
|
|
|
95
|
-
Returns **
|
|
96
|
+
Returns **AsyncIterator<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** transformed source
|
|
96
97
|
|
|
97
98
|
# install
|
|
98
99
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Function} ExpressionTransformer
|
|
3
|
+
* @param {string} expression detected expression without leadIn / leadOut
|
|
4
|
+
* @param {string} remainder chunk after leadOut
|
|
5
|
+
* @param {Iterable<string>} source original source
|
|
6
|
+
* @param {EarlyConsumerCallback} cb to be called if remainder has changed
|
|
7
|
+
* @param {string} leadIn expression entry sequence
|
|
8
|
+
* @param {string} leadOut expression exit sequence
|
|
9
|
+
* @return {AsyncIterable<string>} transformed source
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
13
|
+
* @typedef {Function} EarlyConsumerCallback
|
|
14
|
+
* @param {string} remainder new remainder to be used by iterableStringInterceptor
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Intercept into a async iterable string source, detecting lead in/outs like '{{' and '}}'
|
|
18
|
+
* and asking a transformer for a replacement iterable string.
|
|
19
|
+
* @param {Iterable<string>} source
|
|
20
|
+
* @param {ExpressionTransformer} transform
|
|
21
|
+
* @param {string} leadIn expression entry sequence
|
|
22
|
+
* @param {string} leadOut expression exit sequence
|
|
23
|
+
* @return {AsyncIterable<string>} transformed source
|
|
24
|
+
*/
|
|
25
|
+
export function iterableStringInterceptor(source: Iterable<string>, transform: ExpressionTransformer, leadIn?: string, leadOut?: string): AsyncIterable<string>;
|
|
26
|
+
export type ExpressionTransformer = Function;
|
|
27
|
+
/**
|
|
28
|
+
* Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
29
|
+
*/
|
|
30
|
+
export type EarlyConsumerCallback = Function;
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-string-interceptor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
6
7
|
},
|
|
7
8
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/iterable-string-interceptor.d.mts",
|
|
11
|
+
"default": "./src/iterable-string-interceptor.mjs"
|
|
12
|
+
}
|
|
9
13
|
},
|
|
14
|
+
"types": "./dist/iterable-string-interceptor.d.mts",
|
|
10
15
|
"description": "Intercept iterable string - backbone for template engines",
|
|
11
16
|
"keywords": [
|
|
12
17
|
"chunk",
|
|
@@ -20,27 +25,30 @@
|
|
|
20
25
|
],
|
|
21
26
|
"license": "BSD-2-Clause",
|
|
22
27
|
"scripts": {
|
|
28
|
+
"prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir dist -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
|
|
23
29
|
"test": "npm run test:browser-ava && npm run test:ava",
|
|
24
|
-
"test:ava": "ava --timeout
|
|
30
|
+
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
25
31
|
"test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
|
|
26
|
-
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout
|
|
32
|
+
"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",
|
|
27
33
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
28
|
-
"lint": "npm run lint:docs",
|
|
29
|
-
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
34
|
+
"lint": "npm run lint:docs && npm run lint:tsc",
|
|
35
|
+
"lint:docs": "documentation lint ./src/**/*.mjs",
|
|
36
|
+
"lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
|
-
"ava": "^
|
|
33
|
-
"browser-ava": "^1.
|
|
34
|
-
"c8": "^
|
|
35
|
-
"documentation": "^14.0.
|
|
36
|
-
"semantic-release": "^
|
|
39
|
+
"ava": "^6.1.1",
|
|
40
|
+
"browser-ava": "^2.1.12",
|
|
41
|
+
"c8": "^9.1.0",
|
|
42
|
+
"documentation": "^14.0.3",
|
|
43
|
+
"semantic-release": "^23.0.2",
|
|
44
|
+
"typescript": "^5.3.3"
|
|
37
45
|
},
|
|
38
46
|
"engines": {
|
|
39
|
-
"node": ">=16.20.
|
|
47
|
+
"node": ">=16.20.2"
|
|
40
48
|
},
|
|
41
49
|
"repository": {
|
|
42
50
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/arlac77/iterable-string-interceptor"
|
|
51
|
+
"url": "git+https://github.com/arlac77/iterable-string-interceptor.git"
|
|
44
52
|
},
|
|
45
53
|
"bugs": {
|
|
46
54
|
"url": "https://github.com/arlac77/iterable-string-interceptor/issues"
|
|
@@ -50,7 +58,8 @@
|
|
|
50
58
|
"inheritFrom": [
|
|
51
59
|
"arlac77/template-arlac77-github",
|
|
52
60
|
"arlac77/template-browser-ava",
|
|
53
|
-
"arlac77/template-
|
|
61
|
+
"arlac77/template-javascript-component",
|
|
62
|
+
"arlac77/template-typescript"
|
|
54
63
|
]
|
|
55
64
|
}
|
|
56
65
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {
|
|
2
|
+
* @typedef {Function} ExpressionTransformer
|
|
3
3
|
* @param {string} expression detected expression without leadIn / leadOut
|
|
4
4
|
* @param {string} remainder chunk after leadOut
|
|
5
5
|
* @param {Iterable<string>} source original source
|
|
6
6
|
* @param {EarlyConsumerCallback} cb to be called if remainder has changed
|
|
7
7
|
* @param {string} leadIn expression entry sequence
|
|
8
8
|
* @param {string} leadOut expression exit sequence
|
|
9
|
-
* @return {
|
|
9
|
+
* @return {AsyncIterable<string>} transformed source
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Will be called from the ExpressionTransformer if the given remainder needs to be altered.
|
|
14
|
-
* @typedef {
|
|
14
|
+
* @typedef {Function} EarlyConsumerCallback
|
|
15
15
|
* @param {string} remainder new remainder to be used by iterableStringInterceptor
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param {ExpressionTransformer} transform
|
|
23
23
|
* @param {string} leadIn expression entry sequence
|
|
24
24
|
* @param {string} leadOut expression exit sequence
|
|
25
|
-
* @return {
|
|
25
|
+
* @return {AsyncIterable<string>} transformed source
|
|
26
26
|
*/
|
|
27
27
|
export async function* iterableStringInterceptor(
|
|
28
28
|
source,
|