puvox-library 1.0.30 → 1.0.31

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/README.md CHANGED
@@ -10,7 +10,10 @@ Include `<script src="https://unpkg.com/puvox-library"></script>` in your front-
10
10
 
11
11
  ## Examples
12
12
  ```
13
- let myVar = PuvoxLibrary.arrayLastItem ( [1,2,3,4,5] );
14
- let myVar = PuvoxLibrary.removeKeys ( {a:11, b:22, c:33}, ['c'] );
15
- // etc, numberous useful methods...
13
+ PuvoxLibrary.arrayValue ( {a:11, b:22, c:33}, 'c' ); // 33
14
+ PuvoxLibrary.arrayRemoveValue ( ["k", "z", "g"] , "z" ); // ["k", "g"]
15
+ PuvoxLibrary.randomNumber (length); // 29873433
16
+ PuvoxLibrary.removeKeys ( {a:11, b:22, c:33}, ['c'] ); // {a:11, b:22}
17
+ PuvoxLibrary.stringToArray ( {a:11, b:22, c:33}, ['c'] ); // {a:11, b:22}
18
+ // etc, numerous useful methods...
16
19
  ```
@@ -442,9 +442,9 @@ const puvox_library =
442
442
  }
443
443
  return obj;
444
444
  },
445
- renameSubKey (obj, keyFrom, keyTo) {
445
+ renameSubKey (obj, keyFrom, keyTo, strict = false) {
446
446
  for (const key of Object.keys(obj)) {
447
- obj[key][keyTo] = obj[key][keyFrom];
447
+ obj[key][keyTo] = strict ? obj[key][keyFrom] : (obj[key][keyFrom] || null);
448
448
  delete obj[key][keyFrom];
449
449
  }
450
450
  return obj;
@@ -1664,7 +1664,7 @@ const puvox_library =
1664
1664
  // ============================= get basename of url ============================
1665
1665
  basename(path) { return path.split('/').reverse()[0]; },
1666
1666
 
1667
-
1667
+
1668
1668
  // ======== simple POPUP ======== https://github.com/ttodua/useful-javascript/ ==============
1669
1669
  show_my_popup(TEXTorID, AdditionalStyles ){
1670
1670
  TEXTorID=TEXTorID.trim(); var FirstChar= TEXTorID.charAt(0); var eName = TEXTorID.substr(1); if ('#'==FirstChar || '.'==FirstChar){ if('#'==FirstChar){var x=document.getElementById(eName);} else{var x=document.getElementsByClassName(eName)[0];}} else { var x=document.createElement('div');x.innerHTML=TEXTorID;} var randm_id=Math.floor((Math.random()*100000000));
@@ -2473,9 +2473,10 @@ const puvox_library =
2473
2473
  // random NUMBER or STRINGS
2474
2474
  RandomNum(maxNum) { return Math.floor((Math.random() * maxNum) + 1); },
2475
2475
 
2476
- random_number(length) { var length= length || 5; return Math.floor((Math.random() * Math.pow(10, length)) + 1);},
2476
+ random_number(Length) { var length= length || 5; return Math.floor((Math.random() * Math.pow(10, length)) + 1);},
2477
+ randomNumber(Length) {return this.random_number(length);},
2477
2478
  random_number_minmax(min, max) { var min= min || 1; var max= max || 9999999999; return Math.floor(Math.random() * (max - min + 1)) + min;},
2478
- randomString(length) { var length= length || 5; return Math.random().toString(36).substr(2, length);},
2479
+ randomString(Length) { var length= length || 5; return Math.random().toString(36).substr(2, length);},
2479
2480
  //getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); },
2480
2481
 
2481
2482
  shuffle_Word(word){
@@ -2728,9 +2729,6 @@ const puvox_library =
2728
2729
 
2729
2730
 
2730
2731
 
2731
-
2732
-
2733
-
2734
2732
  async fetch(url, postOptions = null, opts = {}){
2735
2733
  return await this.getRemoteData(url, postOptions, opts);
2736
2734
  },
@@ -2755,6 +2753,17 @@ const puvox_library =
2755
2753
  },
2756
2754
  // if(setHashInAddress) { window.location.hash = id_or_Name; }
2757
2755
 
2756
+
2757
+ async downloadFile(url, path){
2758
+ const res = await this.fetch(url);
2759
+ const fileStream = this.file.fs().createWriteStream(path);
2760
+ await new Promise((resolve, reject) => {
2761
+ res.body.pipe(fileStream);
2762
+ res.body.on("error", reject);
2763
+ fileStream.on("finish", resolve);
2764
+ });
2765
+ },
2766
+
2758
2767
  unTrailingSlash(str){
2759
2768
  while (str.endsWith('/') || str.endsWith('\\')) {
2760
2769
  str = str.slice(0, -1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puvox-library",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "library-class-javascript",
5
5
  "main": "library_standard.js",
6
6
  "scripts": {