smsmslib 1.0.3 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smsmslib",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Reusable functions for me.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,18 +1,17 @@
1
1
  import {useReducer} from "react";
2
2
 
3
3
 
4
- export function sj_reducer_use(hf_type, o_init, f_init)
4
+ export function sj_reducer_use(hf_type, init, f_init, user)
5
5
  {
6
- const [o_state, f_dispatch] = useReducer(sj_reducer, o_init, f_init);
7
- const o_user = {};
8
- const f_onAction = sj_reducer_onAction(hf_type, f_dispatch, o_user);
9
- const o_reducer = new Reducer_t(o_state, f_onAction, o_user);
6
+ const [value, f_dispatch] = useReducer(sj_reducer, init, f_init);
7
+ const f_onAction = sj_reducer_onAction(hf_type, f_dispatch, user);
8
+ const o_reducer = new Reducer_t(value, f_onAction, user);
10
9
 
11
10
  return o_reducer;
12
11
  }
13
12
 
14
13
 
15
- function sj_reducer_onAction(hf_type, f_dispatch, o_user)
14
+ function sj_reducer_onAction(hf_type, f_dispatch, user)
16
15
  {
17
16
  function onAction(o_event)
18
17
  {
@@ -29,7 +28,7 @@ function sj_reducer_onAction(hf_type, f_dispatch, o_user)
29
28
  type : s_type, /* By convention. */
30
29
  f_type : f_type,
31
30
  o_event: o_event,
32
- o_user : o_user,
31
+ user : user,
33
32
  };
34
33
 
35
34
  f_dispatch(o_action);
@@ -41,18 +40,18 @@ function sj_reducer_onAction(hf_type, f_dispatch, o_user)
41
40
  }
42
41
 
43
42
 
44
- function sj_reducer(o_state, o_action)
43
+ function sj_reducer(value, o_action)
45
44
  {
46
- const o_next = o_action.f_type(o_state, o_action.o_event, o_action.o_user);
45
+ const o_next = o_action.f_type(value, o_action.o_event, o_action.user);
47
46
  return o_next;
48
47
  }
49
48
 
50
49
 
51
- function Reducer_t(o_state, f_onAction, o_user)
50
+ function Reducer_t(value, f_onAction, user)
52
51
  {
53
- this.o_state = o_state;
52
+ this.value = value;
54
53
  this.f_onAction = f_onAction;
55
- this.o_user = o_user;
54
+ this.user = user;
56
55
  }
57
56
 
58
57
 
@@ -0,0 +1,50 @@
1
+ import {useState} from "react";
2
+
3
+
4
+ export function sj_state_use(init, hf_type, user)
5
+ {
6
+ const [value, f_set] = useState(init);
7
+ const f_onAction = sj_state_onAction(value, f_set, hf_type, user);
8
+ const o_state = new State_t(value, f_onAction, user);
9
+
10
+ return o_state;
11
+ }
12
+
13
+
14
+ export function sj_state_onAction(value, f_set, hf_type, user)
15
+ {
16
+ function onAction(o_event)
17
+ {
18
+ const s_type = o_event.target.dataset.s_type;
19
+
20
+ if ((s_type in hf_type) && (f_set !== null))
21
+ {
22
+ const f_type = hf_type[s_type];
23
+
24
+ if (f_type !== null)
25
+ {
26
+ const o_action =
27
+ {
28
+ type : s_type,
29
+ o_event: o_event,
30
+ user : user,
31
+ };
32
+
33
+ const next = f_type(value, o_action);
34
+ f_set(next);
35
+ }
36
+ }
37
+ }
38
+
39
+ return onAction;
40
+ }
41
+
42
+
43
+ function State_t(value, f_onAction, user)
44
+ {
45
+ this.value = value;
46
+ this.f_onAction = f_onAction;
47
+ this.user = user;
48
+ }
49
+
50
+
package/tags_JavaScript CHANGED
@@ -4,7 +4,16 @@
4
4
  !_TAG_PROGRAM_NAME Exuberant Ctags //
5
5
  !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
6
  !_TAG_PROGRAM_VERSION 5.9~svn20110310 //
7
+ Reducer_t /home/sakae/work/react/smsmslib/system/usereducer.js ?^function Reducer_t(value, f_onAction, user)$?;" f
7
8
  State_t /home/sakae/work/react/smsmslib/system/proto.js ?^export function State_t(val, f_set)$?;" f
9
+ State_t /home/sakae/work/react/smsmslib/system/usestate.js ?^function State_t(value, f_onAction, user)$?;" f
8
10
  onAction /home/sakae/work/react/smsmslib/system/proto.js ?^ function onAction(o_eve)$?;" f
11
+ onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^ function onAction(o_event)$?;" f
12
+ onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^ function onAction(o_event)$?;" f
9
13
  sj_onAction_get /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_onAction_get(o_main)$?;" f
14
+ sj_reducer /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer(value, o_action)$?;" f
15
+ sj_reducer_onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer_onAction(hf_type, f_dispatch, user)$?;" f
16
+ sj_reducer_use /home/sakae/work/react/smsmslib/system/usereducer.js ?^export function sj_reducer_use(hf_type, init, f_init, user)$?;" f
17
+ sj_state_onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_state_onAction(value, f_set, hf_type, user)$?;" f
18
+ sj_state_use /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_state_use(init, hf_type, user)$?;" f
10
19
  sj_use_state /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_use_state(ini)$?;" f