soyba-lib 1.0.2 → 1.0.3
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 +1 -1
- package/src/index.js +8 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -54,8 +54,10 @@ class YBAClient {
|
|
|
54
54
|
return { xml: xmlStr, json };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// lib/soyba/src/index.js
|
|
57
58
|
async _decodeAndParseFiles(obj) {
|
|
58
59
|
const results = [];
|
|
60
|
+
const self = this; // ✅ Lưu reference đến this
|
|
59
61
|
|
|
60
62
|
async function traverse(node) {
|
|
61
63
|
if (!node || typeof node !== 'object') return;
|
|
@@ -64,9 +66,11 @@ class YBAClient {
|
|
|
64
66
|
const files = Array.isArray(node.FILEHOSO) ? node.FILEHOSO : [node.FILEHOSO];
|
|
65
67
|
const newFiles = [];
|
|
66
68
|
for (const file of files) {
|
|
67
|
-
if (file && file.NOIDUNGFILE && file.LOAIHOSO &&
|
|
69
|
+
if (file && file.NOIDUNGFILE && file.LOAIHOSO && self._isBase64(file.NOIDUNGFILE)) {
|
|
70
|
+
// ^^^^^ Dùng self thay vì this
|
|
68
71
|
try {
|
|
69
|
-
const decoded = await
|
|
72
|
+
const decoded = await self._decodeFileContent(file.NOIDUNGFILE);
|
|
73
|
+
// ^^^^^ Dùng self
|
|
70
74
|
const minimal = {
|
|
71
75
|
LOAIHOSO: file.LOAIHOSO,
|
|
72
76
|
NOIDUNGFILE_JSON: decoded.json
|
|
@@ -84,11 +88,11 @@ class YBAClient {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
for (const key of Object.keys(node)) {
|
|
87
|
-
if (typeof node[key] === 'object') await traverse.call(this,
|
|
91
|
+
if (typeof node[key] === 'object') await traverse(node[key]); // ✅ Bỏ .call(this, ...)
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
await traverse.call(this,
|
|
95
|
+
await traverse(obj); // ✅ Bỏ .call(this, ...)
|
|
92
96
|
return results;
|
|
93
97
|
}
|
|
94
98
|
|