@thi.ng/transducers-fsm 2.1.30 → 2.2.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/CHANGELOG.md +7 -1
- package/README.md +11 -11
- package/index.d.ts +20 -22
- package/index.js +18 -20
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-12-20T16:33:12Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-fsm@2.2.0) (2022-12-16)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- fix [#358](https://github.com/thi-ng/umbrella/issues/358) add "completed" project status, update pkgs/readmes ([d35fa52](https://github.com/thi-ng/umbrella/commit/d35fa52))
|
|
17
|
+
|
|
12
18
|
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-fsm@2.1.0) (2021-11-17)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/transducers-fsm)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
11
11
|
|
|
12
|
+
**Update 12/2022: This package is considered completed and no longer being
|
|
13
|
+
updated with new features.**
|
|
14
|
+
|
|
12
15
|
- [About](#about)
|
|
13
16
|
- [Status](#status)
|
|
14
17
|
- [Related packages](#related-packages)
|
|
@@ -23,7 +26,7 @@ This project is part of the
|
|
|
23
26
|
|
|
24
27
|
## About
|
|
25
28
|
|
|
26
|
-
Transducer-based Finite State Machine transformer
|
|
29
|
+
Transducer-based Finite State Machine transformer
|
|
27
30
|
|
|
28
31
|
This package provides a single function, a general purpose [Finite State
|
|
29
32
|
Machine](https://en.wikipedia.org/wiki/Finite-state_machine) transducer,
|
|
@@ -33,7 +36,7 @@ transformation pipeline.
|
|
|
33
36
|
|
|
34
37
|
## Status
|
|
35
38
|
|
|
36
|
-
**
|
|
39
|
+
**COMPLETED** - no further development planned
|
|
37
40
|
|
|
38
41
|
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Btransducers-fsm%5D+in%3Atitle)
|
|
39
42
|
|
|
@@ -62,11 +65,8 @@ ES module import:
|
|
|
62
65
|
|
|
63
66
|
For Node.js REPL:
|
|
64
67
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
node --experimental-repl-await
|
|
68
|
-
|
|
69
|
-
> const transducersFsm = await import("@thi.ng/transducers-fsm");
|
|
68
|
+
```js
|
|
69
|
+
const transducersFsm = await import("@thi.ng/transducers-fsm");
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
Package sizes (brotli'd, pre-treeshake): ESM: 213 bytes
|
|
@@ -202,7 +202,7 @@ to the configured `terminate` state, processing is terminated (by calling
|
|
|
202
202
|
|
|
203
203
|
## Authors
|
|
204
204
|
|
|
205
|
-
Karsten Schmidt
|
|
205
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
206
206
|
|
|
207
207
|
If this project contributes to an academic publication, please cite it as:
|
|
208
208
|
|
|
@@ -217,4 +217,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
217
217
|
|
|
218
218
|
## License
|
|
219
219
|
|
|
220
|
-
© 2018 - 2022 Karsten Schmidt // Apache
|
|
220
|
+
© 2018 - 2022 Karsten Schmidt // Apache License 2.0
|
package/index.d.ts
CHANGED
|
@@ -3,37 +3,35 @@ import type { Transducer } from "@thi.ng/transducers";
|
|
|
3
3
|
export interface FSMState {
|
|
4
4
|
state: PropertyKey;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type FSMStateMap<T extends FSMState, A, B> = IObjectOf<FSMHandler<T, A, B>>;
|
|
7
|
+
export type FSMHandler<T extends FSMState, A, B> = (state: T, input: A) => B | null | void;
|
|
8
8
|
export interface FSMOpts<T extends FSMState, A, B> {
|
|
9
9
|
states: FSMStateMap<T, A, B>;
|
|
10
10
|
terminate: PropertyKey;
|
|
11
11
|
init: Fn0<T>;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Finite State Machine transducer. Takes an FSM configuration object
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* outputs per consumed input.
|
|
14
|
+
* Finite State Machine transducer. Takes an FSM configuration object and
|
|
15
|
+
* returns a transducer, which processes inputs using the provided state handler
|
|
16
|
+
* functions, which in turn can return any number of outputs per consumed input.
|
|
18
17
|
*
|
|
19
|
-
* Before processing the first input, the FSM state is initialized by
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* based on given inputs.
|
|
18
|
+
* Before processing the first input, the FSM state is initialized by calling
|
|
19
|
+
* the user provided `init()` function, which MUST return a state object with at
|
|
20
|
+
* least a `state` key, whose value is used for dynamic (i.e. stateful) dispatch
|
|
21
|
+
* during input processing. This state object is passed with each input value to
|
|
22
|
+
* the current state handler, which is expected to mutate this object, e.g. to
|
|
23
|
+
* cause state changes based on given inputs.
|
|
26
24
|
*
|
|
27
|
-
* If a state handler needs to "emit" results for downstream processing,
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
25
|
+
* If a state handler needs to "emit" results for downstream processing, it can
|
|
26
|
+
* return an array of values. Any such values are passed on (individually, not
|
|
27
|
+
* as array) to the next reducer in the chain. If a state handler returns `null`
|
|
28
|
+
* or `undefined`, further downstream processing of the current input is
|
|
29
|
+
* skipped.
|
|
32
30
|
*
|
|
33
|
-
* Regardless of return value, if a state handler has caused a state
|
|
34
|
-
*
|
|
35
|
-
* (
|
|
36
|
-
* inputs will be consumed.
|
|
31
|
+
* Regardless of return value, if a state handler has caused a state change to
|
|
32
|
+
* the configured `terminal` state, processing is terminated (by calling
|
|
33
|
+
* [`ensureReduced()`](https://docs.thi.ng/umbrella/transducers/functions/ensureReduced.html))
|
|
34
|
+
* and no further inputs will be consumed.
|
|
37
35
|
*
|
|
38
36
|
* @example
|
|
39
37
|
* ```ts
|
package/index.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { compR } from "@thi.ng/transducers/compr";
|
|
2
2
|
import { ensureReduced, isReduced } from "@thi.ng/transducers/reduced";
|
|
3
3
|
/**
|
|
4
|
-
* Finite State Machine transducer. Takes an FSM configuration object
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* outputs per consumed input.
|
|
4
|
+
* Finite State Machine transducer. Takes an FSM configuration object and
|
|
5
|
+
* returns a transducer, which processes inputs using the provided state handler
|
|
6
|
+
* functions, which in turn can return any number of outputs per consumed input.
|
|
8
7
|
*
|
|
9
|
-
* Before processing the first input, the FSM state is initialized by
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* based on given inputs.
|
|
8
|
+
* Before processing the first input, the FSM state is initialized by calling
|
|
9
|
+
* the user provided `init()` function, which MUST return a state object with at
|
|
10
|
+
* least a `state` key, whose value is used for dynamic (i.e. stateful) dispatch
|
|
11
|
+
* during input processing. This state object is passed with each input value to
|
|
12
|
+
* the current state handler, which is expected to mutate this object, e.g. to
|
|
13
|
+
* cause state changes based on given inputs.
|
|
16
14
|
*
|
|
17
|
-
* If a state handler needs to "emit" results for downstream processing,
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* If a state handler needs to "emit" results for downstream processing, it can
|
|
16
|
+
* return an array of values. Any such values are passed on (individually, not
|
|
17
|
+
* as array) to the next reducer in the chain. If a state handler returns `null`
|
|
18
|
+
* or `undefined`, further downstream processing of the current input is
|
|
19
|
+
* skipped.
|
|
22
20
|
*
|
|
23
|
-
* Regardless of return value, if a state handler has caused a state
|
|
24
|
-
*
|
|
25
|
-
* (
|
|
26
|
-
* inputs will be consumed.
|
|
21
|
+
* Regardless of return value, if a state handler has caused a state change to
|
|
22
|
+
* the configured `terminal` state, processing is terminated (by calling
|
|
23
|
+
* [`ensureReduced()`](https://docs.thi.ng/umbrella/transducers/functions/ensureReduced.html))
|
|
24
|
+
* and no further inputs will be consumed.
|
|
27
25
|
*
|
|
28
26
|
* @example
|
|
29
27
|
* ```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers-fsm",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Transducer-based Finite State Machine transformer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/transducers": "^8.3.
|
|
37
|
+
"@thi.ng/api": "^8.6.1",
|
|
38
|
+
"@thi.ng/transducers": "^8.3.27"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@microsoft/api-extractor": "^7.33.
|
|
42
|
-
"@thi.ng/testament": "^0.3.
|
|
41
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
42
|
+
"@thi.ng/testament": "^0.3.7",
|
|
43
43
|
"rimraf": "^3.0.2",
|
|
44
44
|
"tools": "^0.0.1",
|
|
45
|
-
"typedoc": "^0.23.
|
|
46
|
-
"typescript": "^4.
|
|
45
|
+
"typedoc": "^0.23.22",
|
|
46
|
+
"typescript": "^4.9.4"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
|
49
49
|
"fsm",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"fsm",
|
|
72
72
|
"sax"
|
|
73
73
|
],
|
|
74
|
-
"status": "
|
|
74
|
+
"status": "completed",
|
|
75
75
|
"year": 2018
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
78
78
|
}
|