@hestia-earth/schema-convert 6.12.0 → 6.15.0
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/convert-csv.js +16 -7
- package/package.json +1 -1
package/convert-csv.js
CHANGED
|
@@ -72,20 +72,29 @@ var listFiles = function (folder) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
72
72
|
});
|
|
73
73
|
}); };
|
|
74
74
|
var processFile = function (filepath, pivot) { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
-
var content, _a, _b, nodes, res, destPath;
|
|
76
|
-
return __generator(this, function (
|
|
77
|
-
switch (
|
|
75
|
+
var content, _a, _b, nodes, res, _c, destPath;
|
|
76
|
+
return __generator(this, function (_d) {
|
|
77
|
+
switch (_d.label) {
|
|
78
78
|
case 0:
|
|
79
79
|
_b = (_a = JSON).parse;
|
|
80
80
|
return [4 /*yield*/, readFile(filepath, encoding)];
|
|
81
81
|
case 1:
|
|
82
|
-
content = _b.apply(_a, [
|
|
82
|
+
content = _b.apply(_a, [_d.sent()]);
|
|
83
83
|
nodes = Array.isArray(content) ? content : ('nodes' in content ? content.nodes : [content]);
|
|
84
|
-
|
|
84
|
+
if (!pivot) return [3 /*break*/, 3];
|
|
85
|
+
return [4 /*yield*/, csv_pivot_1.toCsvPivot(nodes)];
|
|
86
|
+
case 2:
|
|
87
|
+
_c = _d.sent();
|
|
88
|
+
return [3 /*break*/, 4];
|
|
89
|
+
case 3:
|
|
90
|
+
_c = csv_1.toCsv(nodes);
|
|
91
|
+
_d.label = 4;
|
|
92
|
+
case 4:
|
|
93
|
+
res = _c;
|
|
85
94
|
destPath = filepath.replace('.jsonld', '.csv').replace('.json', '.csv');
|
|
86
95
|
return [4 /*yield*/, writeFile(destPath, res, encoding)];
|
|
87
|
-
case
|
|
88
|
-
|
|
96
|
+
case 5:
|
|
97
|
+
_d.sent();
|
|
89
98
|
return [2 /*return*/, destPath];
|
|
90
99
|
}
|
|
91
100
|
});
|