jssm 5.65.9 → 5.65.10
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/dist/es6/jssm.d.ts +65 -17
- package/dist/es6/jssm.js +65 -17
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jssm.d.ts +65 -17
- package/package.json +1 -1
package/jssm.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { version } from './version';
|
|
|
9
9
|
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
10
10
|
*
|
|
11
11
|
* ```typescript
|
|
12
|
-
* import { arrow_direction } from '
|
|
12
|
+
* import { arrow_direction } from 'jssm';
|
|
13
13
|
*
|
|
14
14
|
* arrow_direction('->'); // 'right'
|
|
15
15
|
* arrow_direction('<~=>'); // 'both'
|
|
@@ -22,7 +22,7 @@ declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
|
|
|
22
22
|
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
23
23
|
*
|
|
24
24
|
* ```typescript
|
|
25
|
-
* import { arrow_left_kind } from '
|
|
25
|
+
* import { arrow_left_kind } from 'jssm';
|
|
26
26
|
*
|
|
27
27
|
* arrow_left_kind('<-'); // 'legal'
|
|
28
28
|
* arrow_left_kind('<='); // 'main'
|
|
@@ -38,7 +38,7 @@ declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
38
38
|
* Return the direction of an arrow - `right`, `left`, or `both`.
|
|
39
39
|
*
|
|
40
40
|
* ```typescript
|
|
41
|
-
* import { arrow_left_kind } from '
|
|
41
|
+
* import { arrow_left_kind } from 'jssm';
|
|
42
42
|
*
|
|
43
43
|
* arrow_left_kind('->'); // 'legal'
|
|
44
44
|
* arrow_left_kind('=>'); // 'main'
|
|
@@ -60,7 +60,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
60
60
|
* probably also using {@link compile} and {@link Machine.constructor}.
|
|
61
61
|
*
|
|
62
62
|
* ```typescript
|
|
63
|
-
* import { parse, compile, Machine } from '
|
|
63
|
+
* import { parse, compile, Machine } from 'jssm';
|
|
64
64
|
*
|
|
65
65
|
* const intermediate = wrap_parse('a -> b;', {});
|
|
66
66
|
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
|
|
@@ -85,7 +85,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
85
85
|
* Operator {@link sm}:
|
|
86
86
|
*
|
|
87
87
|
* ```typescript
|
|
88
|
-
* import { sm } from '
|
|
88
|
+
* import { sm } from 'jssm';
|
|
89
89
|
*
|
|
90
90
|
* const switch = sm`on <=> off;`;
|
|
91
91
|
* ```
|
|
@@ -93,7 +93,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
|
|
|
93
93
|
* Method {@link from}:
|
|
94
94
|
*
|
|
95
95
|
* ```typescript
|
|
96
|
-
* import * as jssm from '
|
|
96
|
+
* import * as jssm from 'jssm';
|
|
97
97
|
*
|
|
98
98
|
* const toggle = jssm.from('up <=> down;');
|
|
99
99
|
* ```
|
|
@@ -111,7 +111,7 @@ declare function wrap_parse(input: string, options?: Object): any;
|
|
|
111
111
|
* {@link Machine.construct} to turn the config object into a workable machine.
|
|
112
112
|
*
|
|
113
113
|
* ```typescript
|
|
114
|
-
* import { parse, compile, Machine } from '
|
|
114
|
+
* import { parse, compile, Machine } from 'jssm';
|
|
115
115
|
*
|
|
116
116
|
* const intermediate = parse('a -> b;');
|
|
117
117
|
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
|
|
@@ -136,7 +136,7 @@ declare function wrap_parse(input: string, options?: Object): any;
|
|
|
136
136
|
* Operator {@link sm}:
|
|
137
137
|
*
|
|
138
138
|
* ```typescript
|
|
139
|
-
* import { sm } from '
|
|
139
|
+
* import { sm } from 'jssm';
|
|
140
140
|
*
|
|
141
141
|
* const switch = sm`on <=> off;`;
|
|
142
142
|
* ```
|
|
@@ -144,7 +144,7 @@ declare function wrap_parse(input: string, options?: Object): any;
|
|
|
144
144
|
* Method {@link from}:
|
|
145
145
|
*
|
|
146
146
|
* ```typescript
|
|
147
|
-
* import * as jssm from '
|
|
147
|
+
* import * as jssm from 'jssm';
|
|
148
148
|
*
|
|
149
149
|
* const toggle = jssm.from('up <=> down;');
|
|
150
150
|
* ```
|
|
@@ -224,7 +224,7 @@ declare class Machine<mDT> {
|
|
|
224
224
|
* Get the current state of a machine.
|
|
225
225
|
*
|
|
226
226
|
* ```typescript
|
|
227
|
-
* import * as jssm from '
|
|
227
|
+
* import * as jssm from 'jssm';
|
|
228
228
|
*
|
|
229
229
|
* const switch = jssm.from('on <=> off;');
|
|
230
230
|
* console.log( switch.state() ); // 'on'
|
|
@@ -241,7 +241,7 @@ declare class Machine<mDT> {
|
|
|
241
241
|
* `complete`.)
|
|
242
242
|
*
|
|
243
243
|
* ```typescript
|
|
244
|
-
* import { sm, state_is_final } from '
|
|
244
|
+
* import { sm, state_is_final } from 'jssm';
|
|
245
245
|
*
|
|
246
246
|
* const final_test = sm`first -> second;`;
|
|
247
247
|
*
|
|
@@ -257,7 +257,7 @@ declare class Machine<mDT> {
|
|
|
257
257
|
* `complete`.)
|
|
258
258
|
*
|
|
259
259
|
* ```typescript
|
|
260
|
-
* import { sm, state_is_final } from '
|
|
260
|
+
* import { sm, state_is_final } from 'jssm';
|
|
261
261
|
*
|
|
262
262
|
* const final_test = sm`first -> second;`;
|
|
263
263
|
*
|
|
@@ -289,7 +289,7 @@ declare class Machine<mDT> {
|
|
|
289
289
|
* these states is not guaranteed.
|
|
290
290
|
*
|
|
291
291
|
* ```typescript
|
|
292
|
-
* import * as jssm from '
|
|
292
|
+
* import * as jssm from 'jssm';
|
|
293
293
|
*
|
|
294
294
|
* const switch = jssm.from('on <=> off;');
|
|
295
295
|
* console.log( switch.states() ); // ['on', 'off']
|
|
@@ -303,10 +303,10 @@ declare class Machine<mDT> {
|
|
|
303
303
|
* Check whether the machine knows a given state.
|
|
304
304
|
*
|
|
305
305
|
* ```typescript
|
|
306
|
-
* import * as jssm from '
|
|
306
|
+
* import * as jssm from 'jssm';
|
|
307
307
|
*
|
|
308
308
|
* const switch = jssm.from('on <=> off;');
|
|
309
|
-
|
|
309
|
+
*
|
|
310
310
|
* console.log( switch.has_state('off') ); // true
|
|
311
311
|
* console.log( switch.has_state('dance') ); // false
|
|
312
312
|
* ```
|
|
@@ -327,7 +327,55 @@ declare class Machine<mDT> {
|
|
|
327
327
|
probabilistic_transition(): boolean;
|
|
328
328
|
probabilistic_walk(n: number): Array<StateType>;
|
|
329
329
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
330
|
+
/********
|
|
331
|
+
*
|
|
332
|
+
* List all actions available from this state. Please note that the order of
|
|
333
|
+
* the actions is not guaranteed.
|
|
334
|
+
*
|
|
335
|
+
* ```typescript
|
|
336
|
+
* import { sm } from 'jssm';
|
|
337
|
+
*
|
|
338
|
+
* const machine = sm`
|
|
339
|
+
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
340
|
+
* [red yellow green] 'shutdown' ~> off 'start' -> red;
|
|
341
|
+
* `;
|
|
342
|
+
*
|
|
343
|
+
* console.log( machine.state() ); // logs 'red'
|
|
344
|
+
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
345
|
+
*
|
|
346
|
+
* machine.action('next'); // true
|
|
347
|
+
* console.log( machine.state() ); // logs 'green'
|
|
348
|
+
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
349
|
+
*
|
|
350
|
+
* machine.action('shutdown'); // true
|
|
351
|
+
* console.log( machine.state() ); // logs 'off'
|
|
352
|
+
* console.log( machine.actions() ); // logs ['start']
|
|
353
|
+
*
|
|
354
|
+
* machine.action('start'); // true
|
|
355
|
+
* console.log( machine.state() ); // logs 'red'
|
|
356
|
+
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
*/
|
|
330
360
|
actions(whichState?: StateType): Array<StateType>;
|
|
361
|
+
/********
|
|
362
|
+
*
|
|
363
|
+
* List all states that have a specific action attached. Please note that
|
|
364
|
+
* the order of the states is not guaranteed.
|
|
365
|
+
*
|
|
366
|
+
* ```typescript
|
|
367
|
+
* import { sm } from 'jssm';
|
|
368
|
+
*
|
|
369
|
+
* const machine = sm`
|
|
370
|
+
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
371
|
+
* [red yellow green] 'shutdown' ~> off 'start' -> red;
|
|
372
|
+
* `;
|
|
373
|
+
*
|
|
374
|
+
* console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
|
|
375
|
+
* console.log( machine.list_states_having_action('start') ); // ['off']
|
|
376
|
+
* ```
|
|
377
|
+
*
|
|
378
|
+
*/
|
|
331
379
|
list_states_having_action(whichState: StateType): Array<StateType>;
|
|
332
380
|
list_exit_actions(whichState?: StateType): Array<StateType>;
|
|
333
381
|
probable_action_exits(whichState?: StateType): Array<any>;
|
|
@@ -374,7 +422,7 @@ declare class Machine<mDT> {
|
|
|
374
422
|
*
|
|
375
423
|
*
|
|
376
424
|
* ```typescript
|
|
377
|
-
* import * as jssm from '
|
|
425
|
+
* import * as jssm from 'jssm';
|
|
378
426
|
*
|
|
379
427
|
* const switch = jssm.from('on <=> off;');
|
|
380
428
|
* ```
|
|
@@ -391,7 +439,7 @@ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: a
|
|
|
391
439
|
* template expression.
|
|
392
440
|
*
|
|
393
441
|
* ```typescript
|
|
394
|
-
* import * as jssm from '
|
|
442
|
+
* import * as jssm from 'jssm';
|
|
395
443
|
*
|
|
396
444
|
* const switch = jssm.from('on <=> off;');
|
|
397
445
|
* ```
|