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