smsmslib 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
4
4
  "description": "Reusable functions for me.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,38 +1,37 @@
1
1
  import {useState} from "react";
2
2
 
3
3
 
4
- export function sj_use_state(ini)
4
+ export function sj_state_use(init, hf_type, user)
5
5
  {
6
- const [val, f_set] = useState(ini);
7
- const o_ret = new State_t(val, f_set);
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);
8
9
 
9
- return o_ret;
10
+ return o_state;
10
11
  }
11
12
 
12
13
 
13
- function State_t(value, f_set, f_onAction, o_user)
14
+ export function sj_state_onAction(value, f_set, hf_type, user)
14
15
  {
15
- this.value = value;
16
- this.f_set = f_set;
17
- this.f_onAction = f_onAction;
18
- this.o_user = o_user;
19
- }
20
-
21
-
22
- export function sj_onAction_get(o_main)
23
- {
24
- function onAction(o_eve)
16
+ function onAction(o_event)
25
17
  {
26
- const o_update = o_main.o_update;
27
- const s_type = o_eve.target.dataset.s_type;
18
+ const s_type = o_event.target.dataset.s_type;
28
19
 
29
- if (s_type in o_update)
20
+ if ((s_type in hf_type) && (f_set !== null))
30
21
  {
31
- const ao_next = o_update[s_type](o_main, o_eve);
22
+ const f_type = hf_type[s_type];
32
23
 
33
- for (const o_next of ao_next)
24
+ if (f_type !== null)
34
25
  {
35
- o_next.f_set(o_next.val);
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);
36
35
  }
37
36
  }
38
37
  }
@@ -41,3 +40,11 @@ export function sj_onAction_get(o_main)
41
40
  }
42
41
 
43
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
@@ -6,14 +6,14 @@
6
6
  !_TAG_PROGRAM_VERSION 5.9~svn20110310 //
7
7
  Reducer_t /home/sakae/work/react/smsmslib/system/usereducer.js ?^function Reducer_t(value, f_onAction, user)$?;" f
8
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_set, f_onAction, o_user)$?;" f
9
+ State_t /home/sakae/work/react/smsmslib/system/usestate.js ?^function State_t(value, f_onAction, user)$?;" f
10
10
  onAction /home/sakae/work/react/smsmslib/system/proto.js ?^ function onAction(o_eve)$?;" f
11
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_eve)$?;" f
12
+ onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^ function onAction(o_event)$?;" f
13
13
  sj_onAction_get /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_onAction_get(o_main)$?;" f
14
- sj_onAction_get /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_onAction_get(o_main)$?;" f
15
14
  sj_reducer /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer(value, o_action)$?;" f
16
15
  sj_reducer_onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer_onAction(hf_type, f_dispatch, user)$?;" f
17
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
18
19
  sj_use_state /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_use_state(ini)$?;" f
19
- sj_use_state /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_use_state(ini)$?;" f
package/system/proto.js DELETED
@@ -1,41 +0,0 @@
1
- import {useState} from "react";
2
-
3
-
4
- export function sj_use_state(ini)
5
- {
6
- const [val, f_set] = useState(ini);
7
- const o_ret = new State_t(val, f_set);
8
-
9
- return o_ret;
10
- }
11
-
12
-
13
- export function State_t(val, f_set)
14
- {
15
- this.val = val;
16
- this.f_set = f_set;
17
- }
18
-
19
-
20
- export function sj_onAction_get(o_main)
21
- {
22
- function onAction(o_eve)
23
- {
24
- const o_update = o_main.o_update;
25
- const s_type = o_eve.target.dataset.s_type;
26
-
27
- if (s_type in o_update)
28
- {
29
- const ao_next = o_update[s_type](o_main, o_eve);
30
-
31
- for (const o_next of ao_next)
32
- {
33
- o_next.f_set(o_next.val);
34
- }
35
- }
36
- }
37
-
38
- return onAction;
39
- }
40
-
41
-