@blackglory/structures 0.3.0 → 0.3.4

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.
@@ -6,6 +6,7 @@ export declare class FiniteStateMachine<State extends string, Event extends stri
6
6
  get state(): State;
7
7
  constructor(schema: IFiniteStateMachineSchema<State, Event>, initialState: State);
8
8
  matches(state: State): boolean;
9
+ can(event: Event): boolean;
9
10
  send(event: Event): void;
10
11
  }
11
12
  export declare class BadEventError extends CustomError {
@@ -26,8 +26,11 @@ class FiniteStateMachine {
26
26
  matches(state) {
27
27
  return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f") === state;
28
28
  }
29
+ can(event) {
30
+ return event in this.schema[this.state];
31
+ }
29
32
  send(event) {
30
- if (event in this.schema[this.state]) {
33
+ if (this.can(event)) {
31
34
  __classPrivateFieldSet(this, _FiniteStateMachine_state, this.schema[this.state][event], "f");
32
35
  }
33
36
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"finite-state-machine.js","sourceRoot":"","sources":["../../src/finite-state-machine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAKhD,MAAa,kBAAkB;IAM7B,YACY,MAA+C,EACzD,YAAmB;QADT,WAAM,GAAN,MAAM,CAAyC;QAN3D,4CAAa;QASX,uBAAA,IAAI,6BAAU,YAAY,MAAA,CAAA;IAC5B,CAAC;IATD,IAAI,KAAK;QACP,OAAO,uBAAA,IAAI,iCAAO,CAAA;IACpB,CAAC;IASD,OAAO,CAAC,KAAY;QAClB,OAAO,uBAAA,IAAI,iCAAO,KAAK,KAAK,CAAA;IAC9B,CAAC;IAKD,IAAI,CAAC,KAAY;QACf,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACpC,uBAAA,IAAI,6BAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAE,MAAA,CAAA;SAC9C;a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IACxD,CAAC;CACF;AAJD,sCAIC"}
@@ -6,6 +6,7 @@ export declare class FiniteStateMachine<State extends string, Event extends stri
6
6
  get state(): State;
7
7
  constructor(schema: IFiniteStateMachineSchema<State, Event>, initialState: State);
8
8
  matches(state: State): boolean;
9
+ can(event: Event): boolean;
9
10
  send(event: Event): void;
10
11
  }
11
12
  export declare class BadEventError extends CustomError {
@@ -26,8 +26,11 @@ class FiniteStateMachine {
26
26
  matches(state) {
27
27
  return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f") === state;
28
28
  }
29
+ can(event) {
30
+ return event in this.schema[this.state];
31
+ }
29
32
  send(event) {
30
- if (event in this.schema[this.state]) {
33
+ if (this.can(event)) {
31
34
  __classPrivateFieldSet(this, _FiniteStateMachine_state, this.schema[this.state][event], "f");
32
35
  }
33
36
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"finite-state-machine.js","sourceRoot":"","sources":["../../src/finite-state-machine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAKhD,MAAa,kBAAkB;IAM7B,YACY,MAA+C,EACzD,YAAmB;QADT,WAAM,GAAN,MAAM,CAAyC;QAN3D,4CAAa;QASX,uBAAA,IAAI,6BAAU,YAAY,MAAA,CAAA;IAC5B,CAAC;IATD,IAAI,KAAK;QACP,OAAO,uBAAA,IAAI,iCAAO,CAAA;IACpB,CAAC;IASD,OAAO,CAAC,KAAY;QAClB,OAAO,uBAAA,IAAI,iCAAO,KAAK,KAAK,CAAA;IAC9B,CAAC;IAKD,IAAI,CAAC,KAAY;QACf,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACpC,uBAAA,IAAI,6BAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAE,MAAA,CAAA;SAC9C;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;SAC3C;IACH,CAAC;CACF;AA3BD,gDA2BC;;AAED,MAAa,aAAc,SAAQ,oBAAW;IAC5C,YAAY,KAAa,EAAE,KAAa;QACtC,KAAK,CAAC,SAAS,KAAK,0BAA0B,KAAK,EAAE,CAAC,CAAA;IACxD,CAAC;CACF;AAJD,sCAIC"}
1
+ {"version":3,"file":"finite-state-machine.js","sourceRoot":"","sources":["../../src/finite-state-machine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAKhD,MAAa,kBAAkB;IAM7B,YACY,MAA+C,EACzD,YAAmB;QADT,WAAM,GAAN,MAAM,CAAyC;QAN3D,4CAAa;QASX,uBAAA,IAAI,6BAAU,YAAY,MAAA,CAAA;IAC5B,CAAC;IATD,IAAI,KAAK;QACP,OAAO,uBAAA,IAAI,iCAAO,CAAA;IACpB,CAAC;IASD,OAAO,CAAC,KAAY;QAClB,OAAO,uBAAA,IAAI,iCAAO,KAAK,KAAK,CAAA;IAC9B,CAAC;IAED,GAAG,CAAC,KAAY;QACd,OAAO,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC;IAKD,IAAI,CAAC,KAAY;QACf,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,uBAAA,IAAI,6BAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAE,MAAA,CAAA;SAC9C;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;SAC3C;IACH,CAAC;CACF;AA/BD,gDA+BC;;AAED,MAAa,aAAc,SAAQ,oBAAW;IAC5C,YAAY,KAAa,EAAE,KAAa;QACtC,KAAK,CAAC,SAAS,KAAK,0BAA0B,KAAK,EAAE,CAAC,CAAA;IACxD,CAAC;CACF;AAJD,sCAIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackglory/structures",
3
- "version": "0.3.0",
3
+ "version": "0.3.4",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib",
@@ -8,6 +8,7 @@
8
8
  ],
9
9
  "main": "lib/es2018/index.js",
10
10
  "types": "lib/es2018/index.d.ts",
11
+ "sideEffects": false,
11
12
  "repository": "git@github.com:BlackGlory/structures.git",
12
13
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
13
14
  "license": "MIT",
@@ -40,39 +41,39 @@
40
41
  "node": ">=12"
41
42
  },
42
43
  "devDependencies": {
43
- "@blackglory/jest-matchers": "^0.1.21",
44
- "@commitlint/cli": "^15.0.0",
45
- "@commitlint/config-conventional": "^15.0.0",
44
+ "@blackglory/jest-matchers": "^0.2.1",
45
+ "@commitlint/cli": "^16.2.1",
46
+ "@commitlint/config-conventional": "^16.2.1",
46
47
  "@rollup/plugin-commonjs": "^21.0.1",
47
48
  "@rollup/plugin-json": "^4.1.0",
48
- "@rollup/plugin-node-resolve": "^13.0.6",
49
- "@rollup/plugin-replace": "^3.0.0",
49
+ "@rollup/plugin-node-resolve": "^13.1.3",
50
+ "@rollup/plugin-replace": "^3.1.0",
50
51
  "@rollup/plugin-typescript": "^8.3.0",
51
- "@types/jest": "^27.0.3",
52
- "@types/node": "^16.11.12",
53
- "@typescript-eslint/eslint-plugin": "^5.6.0",
54
- "@typescript-eslint/parser": "^5.6.0",
55
- "eslint": "^8.4.1",
56
- "extra-promise": "^0.19.4",
52
+ "@types/jest": "^27.4.0",
53
+ "@types/node": "14",
54
+ "@typescript-eslint/eslint-plugin": "^5.12.0",
55
+ "@typescript-eslint/parser": "^5.12.0",
56
+ "eslint": "^8.9.0",
57
+ "extra-promise": "^0.21.2",
57
58
  "husky": "^4.3.8",
58
- "iterable-operator": "^0.14.4",
59
- "jest": "^27.4.4",
59
+ "jest": "^27.5.1",
60
60
  "npm-run-all": "^4.1.5",
61
- "return-style": "^0.12.5",
61
+ "return-style": "^0.12.6",
62
62
  "rimraf": "^3.0.2",
63
- "rollup": "^2.61.1",
63
+ "rollup": "^2.67.2",
64
64
  "rollup-plugin-analyzer": "^4.0.0",
65
65
  "rollup-plugin-terser": "^7.0.2",
66
66
  "standard-version": "^9.3.2",
67
- "ts-jest": "^27.1.1",
67
+ "ts-jest": "^27.1.3",
68
68
  "tscpaths": "^0.0.9",
69
69
  "tslib": "^2.3.1",
70
- "typescript": "^4.5.3"
70
+ "typescript": "^4.5.5"
71
71
  },
72
72
  "dependencies": {
73
- "@blackglory/errors": "^1.1.2",
74
- "@blackglory/types": "^0.5.2",
75
- "extra-timers": "^0.2.4",
76
- "rxjs": "^7.4.0"
73
+ "@blackglory/errors": "^2.2.0",
74
+ "@blackglory/types": "^0.6.5",
75
+ "extra-timers": "^0.2.5",
76
+ "iterable-operator": "^0.14.5",
77
+ "rxjs": "^7.5.4"
77
78
  }
78
79
  }
package/CHANGELOG.md DELETED
@@ -1,166 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ## [0.3.0](https://github.com/BlackGlory/structures/compare/v0.2.8...v0.3.0) (2021-12-13)
6
-
7
-
8
- ### ⚠ BREAKING CHANGES
9
-
10
- * Replace `ObervableFiniteStateMachine.stateChangedObservable` with
11
- `observeStateChanges()`
12
-
13
- * replace stateChangedObservable with observeStateChanges ([9708384](https://github.com/BlackGlory/structures/commit/970838452b2ef3b6299379b393eb45fbbc488e55))
14
-
15
- ### [0.2.8](https://github.com/BlackGlory/structures/compare/v0.2.7...v0.2.8) (2021-12-13)
16
-
17
-
18
- ### Features
19
-
20
- * add FiniteStateMachine ([219d440](https://github.com/BlackGlory/structures/commit/219d440b5bb0bc6684166dc2d13d786285368c27))
21
- * add ObservableFiniteStateMachine ([49e3b97](https://github.com/BlackGlory/structures/commit/49e3b97c2238b1567f7588b6c337063c40e0eec9))
22
-
23
- ### [0.2.7](https://github.com/BlackGlory/structures/compare/v0.2.6...v0.2.7) (2021-12-13)
24
-
25
-
26
- ### Features
27
-
28
- * add Box ([bce499f](https://github.com/BlackGlory/structures/commit/bce499f4debbed179c628fa1b3917f9ba2f9e513))
29
-
30
- ### [0.2.6](https://github.com/BlackGlory/structures/compare/v0.2.5...v0.2.6) (2021-10-14)
31
-
32
- ### [0.2.5](https://github.com/BlackGlory/structures/compare/v0.2.4...v0.2.5) (2021-09-16)
33
-
34
-
35
- ### Features
36
-
37
- * add ExpirableMap ([70d2bc3](https://github.com/BlackGlory/structures/commit/70d2bc359be26aa8719fd81286918989bd9cf265))
38
- * add TLRUMap ([21c5460](https://github.com/BlackGlory/structures/commit/21c5460b122c976a4e551d422ddfa3b3cdadd093))
39
-
40
- ### [0.2.4](https://github.com/BlackGlory/structures/compare/v0.2.3...v0.2.4) (2021-09-15)
41
-
42
-
43
- ### Bug Fixes
44
-
45
- * memory leak ([ea8c035](https://github.com/BlackGlory/structures/commit/ea8c035a28b80fad4df411cf4f07d07abe594ee8))
46
-
47
- ### [0.2.3](https://github.com/BlackGlory/structures/compare/v0.2.2...v0.2.3) (2021-07-28)
48
-
49
-
50
- ### Features
51
-
52
- * add HashMap ([f605460](https://github.com/BlackGlory/structures/commit/f605460e766c4117cb64bd2be552cfc300281aa8))
53
-
54
- ### [0.2.2](https://github.com/BlackGlory/structures/compare/v0.2.1...v0.2.2) (2021-07-04)
55
-
56
- ### [0.2.1](https://github.com/BlackGlory/structures/compare/v0.2.0...v0.2.1) (2021-05-16)
57
-
58
- ## [0.2.0](https://github.com/BlackGlory/structures/compare/v0.1.15...v0.2.0) (2021-05-16)
59
-
60
-
61
- ### ⚠ BREAKING CHANGES
62
-
63
- * rewrite
64
- * rename LRU to LRUMap
65
-
66
- ### Features
67
-
68
- * add LRU#clear, LRU#delete ([cdac3dc](https://github.com/BlackGlory/structures/commit/cdac3dcb1521abb0360d04f36097cc9b8027a09c))
69
- * improve Cons ([4564103](https://github.com/BlackGlory/structures/commit/456410346050b5c83c11c85808f447ffcb3484b2))
70
- * improve HashSet, Queue ([da0f515](https://github.com/BlackGlory/structures/commit/da0f5150c04af76d1dc93f2227e00099dacb0280))
71
- * rewrite ([902152b](https://github.com/BlackGlory/structures/commit/902152b0ed00fcb44b90df7e443b62a6147d796a))
72
-
73
-
74
- ### Bug Fixes
75
-
76
- * bundle ([0abacc1](https://github.com/BlackGlory/structures/commit/0abacc18c95884206ecb7d6323614bae826ff38c))
77
-
78
-
79
- * rename LRU to LRUMap ([7f0b8bb](https://github.com/BlackGlory/structures/commit/7f0b8bb3c35cd72bb8b9705ad0c40f09cc2353a2))
80
-
81
- ### [0.1.15](https://github.com/BlackGlory/structures/compare/v0.1.14...v0.1.15) (2021-05-15)
82
-
83
-
84
- ### Features
85
-
86
- * add LRU ([c1f8550](https://github.com/BlackGlory/structures/commit/c1f855022a4c4ac770fddc7d59aed1cfcf49d75f))
87
-
88
- ### [0.1.14](https://github.com/BlackGlory/structures/compare/v0.1.13...v0.1.14) (2021-03-16)
89
-
90
-
91
- ### Features
92
-
93
- * add Queue#remove ([b5f4ad6](https://github.com/BlackGlory/structures/commit/b5f4ad65c43f74edca9bafa43db9dad8b33ad098))
94
-
95
- ### [0.1.13](https://github.com/BlackGlory/structures/compare/v0.1.12...v0.1.13) (2021-02-28)
96
-
97
-
98
- ### Features
99
-
100
- * add Cons ([2a5effa](https://github.com/BlackGlory/structures/commit/2a5effa269cd5089763b458aa749d9b29ea76492))
101
-
102
- ### [0.1.12](https://github.com/BlackGlory/structures/compare/v0.1.11...v0.1.12) (2021-02-04)
103
-
104
- ### [0.1.11](https://github.com/BlackGlory/structures/compare/v0.1.10...v0.1.11) (2021-02-03)
105
-
106
-
107
- ### Bug Fixes
108
-
109
- * bundle ([5206cfa](https://github.com/BlackGlory/structures/commit/5206cfa0947330843ef052e69283844661fbc465))
110
-
111
- ### [0.1.10](https://github.com/BlackGlory/structures/compare/v0.1.9...v0.1.10) (2021-02-03)
112
-
113
- ### [0.1.9](https://github.com/BlackGlory/structures/compare/v0.1.8...v0.1.9) (2021-01-20)
114
-
115
- ### [0.1.8](https://github.com/BlackGlory/structures/compare/v0.1.7...v0.1.8) (2021-01-15)
116
-
117
-
118
- ### Bug Fixes
119
-
120
- * esm bundle ([7fa7e00](https://github.com/BlackGlory/structures/commit/7fa7e004ec290c1ecb4e7e7f4dcb5bc5c472cbd9))
121
-
122
- ### [0.1.7](https://github.com/BlackGlory/structures/compare/v0.1.6...v0.1.7) (2021-01-15)
123
-
124
- ### [0.1.6](https://github.com/BlackGlory/structures/compare/v0.1.5...v0.1.6) (2021-01-05)
125
-
126
-
127
- ### Features
128
-
129
- * add empty ([d66a13b](https://github.com/BlackGlory/structures/commit/d66a13b3b737fd825e265079897640ba07996dda))
130
-
131
- ### [0.1.5](https://github.com/BlackGlory/structures/compare/v0.1.4...v0.1.5) (2021-01-04)
132
-
133
-
134
- ### Bug Fixes
135
-
136
- * bundle ([4fa790b](https://github.com/BlackGlory/structures/commit/4fa790bc06f08dc7adb6bd27ac43345dce1e00f7))
137
-
138
- ### [0.1.4](https://github.com/BlackGlory/structures/compare/v0.1.3...v0.1.4) (2021-01-03)
139
-
140
- ### [0.1.3](https://github.com/BlackGlory/structures/compare/v0.1.2...v0.1.3) (2020-12-19)
141
-
142
-
143
- ### Features
144
-
145
- * add methods ([55266e9](https://github.com/BlackGlory/structures/commit/55266e94a0d6035121a360404617c538a97f4143))
146
-
147
- ### [0.1.2](https://github.com/BlackGlory/structures/compare/v0.1.1...v0.1.2) (2020-12-19)
148
-
149
-
150
- ### Features
151
-
152
- * add Emitter ([0cbcddc](https://github.com/BlackGlory/structures/commit/0cbcddca5520a0e5a496950936ef487634acd252))
153
-
154
- ### [0.1.1](https://github.com/BlackGlory/structures/compare/v0.1.0...v0.1.1) (2020-12-19)
155
-
156
-
157
- ### Features
158
-
159
- * add HashSet ([3cd0b59](https://github.com/BlackGlory/structures/commit/3cd0b59a5a06eeb9c99e23d634b2116eab3de090))
160
-
161
- ## 0.1.0 (2020-12-19)
162
-
163
-
164
- ### Features
165
-
166
- * add Queue ([dfd0c23](https://github.com/BlackGlory/structures/commit/dfd0c237753f4030bb5de11bf311b96170649216))