smsmslib 1.0.85 → 1.0.87
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/javascr/util/deepwalk.js +17 -10
- package/package.json +2 -2
package/javascr/util/deepwalk.js
CHANGED
|
@@ -39,6 +39,7 @@ import
|
|
|
39
39
|
{
|
|
40
40
|
sj_prop_get_own,
|
|
41
41
|
sj_prop_set_own,
|
|
42
|
+
sj_keys,
|
|
42
43
|
}
|
|
43
44
|
from "./prop.js";
|
|
44
45
|
|
|
@@ -49,6 +50,12 @@ import
|
|
|
49
50
|
}
|
|
50
51
|
from "./tree.js";
|
|
51
52
|
|
|
53
|
+
import
|
|
54
|
+
{
|
|
55
|
+
sj_deep_get_own,
|
|
56
|
+
}
|
|
57
|
+
from "./deep.js";
|
|
58
|
+
|
|
52
59
|
|
|
53
60
|
/** ---------------------------------------------------------------------------
|
|
54
61
|
* Functions.
|
|
@@ -72,7 +79,7 @@ from "./tree.js";
|
|
|
72
79
|
* The user-defined callback function called at each node.
|
|
73
80
|
* Expected signature: `f_cb(ao_TreeStack, i_depth, user)`
|
|
74
81
|
* - ao_TreeStack: The current traversal stack.
|
|
75
|
-
* - i_depth: The maximum depth limit passed to `
|
|
82
|
+
* - i_depth: The maximum depth limit passed to `sj_deepwalk`.
|
|
76
83
|
* - user: The user data provided.
|
|
77
84
|
* Must return `true` to continue or `false` to abort.
|
|
78
85
|
*
|
|
@@ -83,7 +90,7 @@ from "./tree.js";
|
|
|
83
90
|
* Status code defined in `go_tree_walk_ret`. Same as `sj_tree_walk`.
|
|
84
91
|
* @see sj_tree_walk
|
|
85
92
|
*/
|
|
86
|
-
export function
|
|
93
|
+
export function sj_deepwalk(value, i_depth, f_cb, user)
|
|
87
94
|
{
|
|
88
95
|
let i_ret = go_tree_walk_ret.i_noncb;
|
|
89
96
|
|
|
@@ -95,11 +102,11 @@ export function sj_deep_walk(value, i_depth, f_cb, user)
|
|
|
95
102
|
|
|
96
103
|
if (o_user)
|
|
97
104
|
{
|
|
98
|
-
const o_root =
|
|
105
|
+
const o_root = deepwalk_node_t(value);
|
|
99
106
|
|
|
100
107
|
if (o_root)
|
|
101
108
|
{
|
|
102
|
-
i_ret = sj_tree_walk(
|
|
109
|
+
i_ret = sj_tree_walk(deepwalk_cb, o_root, o_user);
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
}
|
|
@@ -113,7 +120,7 @@ export function sj_deep_walk(value, i_depth, f_cb, user)
|
|
|
113
120
|
*
|
|
114
121
|
* This function serves two primary purposes:
|
|
115
122
|
* 1. **Node Adaptation**: It wraps the next child value into a node object
|
|
116
|
-
* using `
|
|
123
|
+
* using `deepwalk_node_t` for the next step of traversal.
|
|
117
124
|
* 2. **User Callback Execution**: It triggers the user-provided callback
|
|
118
125
|
* (`o_user.f_cb`) in "leading order".
|
|
119
126
|
*
|
|
@@ -132,7 +139,7 @@ export function sj_deep_walk(value, i_depth, f_cb, user)
|
|
|
132
139
|
* @returns {boolean}
|
|
133
140
|
* true to continue the traversal; otherwise false to abort.
|
|
134
141
|
*/
|
|
135
|
-
function
|
|
142
|
+
function deepwalk_cb(ao_TreeStack, from_child, o_user)
|
|
136
143
|
{
|
|
137
144
|
let b_continue = true;
|
|
138
145
|
const b_depth = (o_user.i_depth < 1) || (ao_TreeStack.length <= o_user.i_depth);
|
|
@@ -145,7 +152,7 @@ function deep_walk_cb(ao_TreeStack, from_child, o_user)
|
|
|
145
152
|
{
|
|
146
153
|
const s_key = o_node.as_key[o_TreeStack.i_child];
|
|
147
154
|
|
|
148
|
-
o_TreeStack.child =
|
|
155
|
+
o_TreeStack.child = deepwalk_node_t(o_node.value[s_key]);
|
|
149
156
|
b_continue &&= (!!o_TreeStack.child);
|
|
150
157
|
}
|
|
151
158
|
|
|
@@ -164,7 +171,7 @@ function deep_walk_cb(ao_TreeStack, from_child, o_user)
|
|
|
164
171
|
*
|
|
165
172
|
* This function reconstructs the path by iterating through the tree stack
|
|
166
173
|
* from the root up to the parent of the current node. It is designed to be
|
|
167
|
-
* called within a callback of `
|
|
174
|
+
* called within a callback of `sj_deepwalk`.
|
|
168
175
|
*
|
|
169
176
|
* Since the last element of `ao_TreeStack` represents the current node itself,
|
|
170
177
|
* this function collects keys from all elements except the last to form the
|
|
@@ -178,7 +185,7 @@ function deep_walk_cb(ao_TreeStack, from_child, o_user)
|
|
|
178
185
|
* otherwise null if the stack is invalid or an internal error occurs.
|
|
179
186
|
* Note: Returns an empty array if the current node is the root.
|
|
180
187
|
*/
|
|
181
|
-
export function
|
|
188
|
+
export function sj_deepwalk_path(ao_TreeStack)
|
|
182
189
|
{
|
|
183
190
|
let as_path = sj_array_new(0);
|
|
184
191
|
const b_arr = Array.isArray(ao_TreeStack);
|
|
@@ -227,7 +234,7 @@ export function sj_deep_path(ao_TreeStack)
|
|
|
227
234
|
* otherwise null.
|
|
228
235
|
* Returns null if the node object cannot be created.
|
|
229
236
|
*/
|
|
230
|
-
function
|
|
237
|
+
function deepwalk_node_t(value)
|
|
231
238
|
{
|
|
232
239
|
let o_node = null;
|
|
233
240
|
let as_key = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smsmslib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.87",
|
|
4
4
|
"description": "Reusable functions for me.",
|
|
5
5
|
"files": [
|
|
6
6
|
"javascr/**/*.js",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"smsmslib": "^1.0.
|
|
22
|
+
"smsmslib": "^1.0.87"
|
|
23
23
|
}
|
|
24
24
|
}
|