puvox-library 1.0.5 → 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/library_standard.js +19 -3
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -2648,9 +2648,16 @@ const puvox_library =
|
|
2648
2648
|
return this._fs_instance;
|
2649
2649
|
}
|
2650
2650
|
},
|
2651
|
-
async getRemoteData(url){
|
2651
|
+
async getRemoteData(url, postOptions = null, opts = {}){
|
2652
2652
|
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
|
2653
|
-
|
2653
|
+
const options = {};
|
2654
|
+
if (postOptions) {
|
2655
|
+
options['method'] = 'POST';
|
2656
|
+
options['body'] = JSON.stringify(postOptions);
|
2657
|
+
}
|
2658
|
+
options['headers'] = ('headers' in opts) ? opts.headers : {'Content-Type': 'application/json'};
|
2659
|
+
const fetched = await fetch(url, options);
|
2660
|
+
return await (fetched).text();
|
2654
2661
|
// return new Promise ((resolve, reject) => {
|
2655
2662
|
// try {
|
2656
2663
|
// // const https = require('https');
|
@@ -2670,7 +2677,7 @@ const puvox_library =
|
|
2670
2677
|
}
|
2671
2678
|
let jsonNew = self.jsonConcat(json, jsonContent);
|
2672
2679
|
let content = JSON.stringify(jsonNew);
|
2673
|
-
|
2680
|
+
self.fs().writeFile(filePath, content, 'utf8', function(callback_) {
|
2674
2681
|
});
|
2675
2682
|
});
|
2676
2683
|
}
|
@@ -2678,6 +2685,15 @@ const puvox_library =
|
|
2678
2685
|
console.log("writeFileAppendJson", e);
|
2679
2686
|
}
|
2680
2687
|
},
|
2688
|
+
getFilesListFromDir (dir) {
|
2689
|
+
const filesList = [];
|
2690
|
+
this.fs().readdirSync(dir, (err, files) => {
|
2691
|
+
files.forEach(file => {
|
2692
|
+
filesList.push(file);
|
2693
|
+
});
|
2694
|
+
});
|
2695
|
+
return filesList;
|
2696
|
+
},
|
2681
2697
|
// if(setHashInAddress) { window.location.hash = id_or_Name; }
|
2682
2698
|
|
2683
2699
|
|