@vbarbarosh/node-helpers 3.63.0 → 3.63.1

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/dist/browser.js CHANGED
@@ -1,10 +1,47 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ "./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore).*(?<%21\\.test)\\.js$":
5
- /*!***********************************************************************************************************************************************************************************************************************************************************************************!*\
6
- !*** ./src/ sync \b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore).*(?<%21\.test)\.js$ ***!
7
- \***********************************************************************************************************************************************************************************************************************************************************************************/
4
+ /***/ "./node_modules/json-stringify-safe/stringify.js":
5
+ /*!*******************************************************!*\
6
+ !*** ./node_modules/json-stringify-safe/stringify.js ***!
7
+ \*******************************************************/
8
+ /***/ ((module, exports) => {
9
+
10
+ exports = module.exports = stringify
11
+ exports.getSerialize = serializer
12
+
13
+ function stringify(obj, replacer, spaces, cycleReplacer) {
14
+ return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces)
15
+ }
16
+
17
+ function serializer(replacer, cycleReplacer) {
18
+ var stack = [], keys = []
19
+
20
+ if (cycleReplacer == null) cycleReplacer = function(key, value) {
21
+ if (stack[0] === value) return "[Circular ~]"
22
+ return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]"
23
+ }
24
+
25
+ return function(key, value) {
26
+ if (stack.length > 0) {
27
+ var thisPos = stack.indexOf(this)
28
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
29
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
30
+ if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value)
31
+ }
32
+ else stack.push(value)
33
+
34
+ return replacer == null ? value : replacer.call(this, key, value)
35
+ }
36
+ }
37
+
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore%7Cformat%7Cplural%7Crandom_int%7Curlmod%7Cwaitcb)[^/]*(?<%21\\.test)\\.js$":
42
+ /*!***************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
43
+ !*** ./src/ sync \b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore%7Cformat%7Cplural%7Crandom_int%7Curlmod%7Cwaitcb)[^/]*(?<%21\.test)\.js$ ***!
44
+ \***************************************************************************************************************************************************************************************************************************************************************************************************************************************/
8
45
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9
46
 
10
47
  var map = {
@@ -24,6 +61,20 @@ var map = {
24
61
  "./array_unique_last.js": "./src/array_unique_last.js",
25
62
  "./date_add_months.js": "./src/date_add_months.js",
26
63
  "./date_is_leap_year.js": "./src/date_is_leap_year.js",
64
+ "./format_bytes.js": "./src/format_bytes.js",
65
+ "./format_date.js": "./src/format_date.js",
66
+ "./format_date_ymd.js": "./src/format_date_ymd.js",
67
+ "./format_error_report.js": "./src/format_error_report.js",
68
+ "./format_hrtime.js": "./src/format_hrtime.js",
69
+ "./format_kilo.js": "./src/format_kilo.js",
70
+ "./format_ms.js": "./src/format_ms.js",
71
+ "./format_ms2.js": "./src/format_ms2.js",
72
+ "./format_ms3.js": "./src/format_ms3.js",
73
+ "./format_percents.js": "./src/format_percents.js",
74
+ "./format_progress_bytes.js": "./src/format_progress_bytes.js",
75
+ "./format_progress_kilo.js": "./src/format_progress_kilo.js",
76
+ "./format_seconds.js": "./src/format_seconds.js",
77
+ "./format_thousands.js": "./src/format_thousands.js",
27
78
  "./http_delete.js": "./src/http_delete.js",
28
79
  "./http_get_blob.js": "./src/http_get_blob.js",
29
80
  "./http_get_buffer.js": "./src/http_get_buffer.js",
@@ -37,7 +88,11 @@ var map = {
37
88
  "./http_put_json.js": "./src/http_put_json.js",
38
89
  "./http_put_utf8.js": "./src/http_put_utf8.js",
39
90
  "./identity.js": "./src/identity.js",
40
- "./ignore.js": "./src/ignore.js"
91
+ "./ignore.js": "./src/ignore.js",
92
+ "./plural.js": "./src/plural.js",
93
+ "./random_int.js": "./src/random_int.js",
94
+ "./urlmod.js": "./src/urlmod.js",
95
+ "./waitcb.js": "./src/waitcb.js"
41
96
  };
42
97
 
43
98
 
@@ -58,7 +113,7 @@ webpackContext.keys = function webpackContextKeys() {
58
113
  };
59
114
  webpackContext.resolve = webpackContextResolve;
60
115
  module.exports = webpackContext;
61
- webpackContext.id = "./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore).*(?<%21\\.test)\\.js$";
116
+ webpackContext.id = "./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore%7Cformat%7Cplural%7Crandom_int%7Curlmod%7Cwaitcb)[^/]*(?<%21\\.test)\\.js$";
62
117
 
63
118
  /***/ }),
64
119
 
@@ -555,6 +610,26 @@ function date_is_leap_year(d)
555
610
  module.exports = date_is_leap_year;
556
611
 
557
612
 
613
+ /***/ }),
614
+
615
+ /***/ "./src/factorize_ms.js":
616
+ /*!*****************************!*\
617
+ !*** ./src/factorize_ms.js ***!
618
+ \*****************************/
619
+ /***/ ((module) => {
620
+
621
+ function factorize_ms(v)
622
+ {
623
+ const h = Math.floor(v / 3600000);
624
+ const m = Math.floor(v % 3600000 / 60000);
625
+ const s = Math.floor(v % 60000 / 1000);
626
+ const ms = v % 1000;
627
+ return [h, m, s, ms];
628
+ }
629
+
630
+ module.exports = factorize_ms;
631
+
632
+
558
633
  /***/ }),
559
634
 
560
635
  /***/ "./src/fcmp_strings.js":
@@ -571,6 +646,412 @@ function fcmp_strings(a, b)
571
646
  module.exports = fcmp_strings;
572
647
 
573
648
 
649
+ /***/ }),
650
+
651
+ /***/ "./src/format_bytes.js":
652
+ /*!*****************************!*\
653
+ !*** ./src/format_bytes.js ***!
654
+ \*****************************/
655
+ /***/ ((module) => {
656
+
657
+ /**
658
+ * @link https://stackoverflow.com/a/18650828
659
+ */
660
+ function format_bytes(bytes)
661
+ {
662
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
663
+ if (typeof bytes !== 'number' || Number.isNaN(bytes)) {
664
+ return 'n/a';
665
+ }
666
+ if (!bytes) {
667
+ return '0KB';
668
+ }
669
+ if (bytes < 1024) {
670
+ return '1KB';
671
+ }
672
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
673
+ return `${(bytes / (1024 ** i)).toFixed(bytes > 1024*1024 ? 2 : 0)}${sizes[i]}`.replace(/\.00/, '.0');
674
+ }
675
+
676
+ module.exports = format_bytes;
677
+
678
+ // https://wiki.ubuntu.com/UnitsPolicy
679
+ // > Applications must use SI standard for base-10 units:
680
+ // >
681
+ // > 1 kB = 1,000 bytes (Note: small k)
682
+ // > 1 MB = 1,000 kB = 1,000,000 bytes
683
+ // > 1 GB = 1,000 MB = 1,000,000 kB = 1,000,000,000 bytes
684
+ // > 1 TB = 1,000 GB = 1,000,000 MB = 1,000,000,000 kB = 1,000,000,000,000 bytes
685
+
686
+
687
+ /***/ }),
688
+
689
+ /***/ "./src/format_date.js":
690
+ /*!****************************!*\
691
+ !*** ./src/format_date.js ***!
692
+ \****************************/
693
+ /***/ ((module) => {
694
+
695
+ function format_date(d)
696
+ {
697
+ return d.getFullYear() + `/0${d.getMonth()+1}/0${d.getDate()} 0${d.getHours()}:0${d.getMinutes()}:0${d.getSeconds()}`.replace(/0(\d\d)/g, '$1');
698
+ }
699
+
700
+ module.exports = format_date;
701
+
702
+
703
+ /***/ }),
704
+
705
+ /***/ "./src/format_date_ymd.js":
706
+ /*!********************************!*\
707
+ !*** ./src/format_date_ymd.js ***!
708
+ \********************************/
709
+ /***/ ((module) => {
710
+
711
+ function format_date_ymd(d)
712
+ {
713
+ return d.getFullYear() + `/0${d.getMonth()+1}/0${d.getDate()}`.replace(/0(\d\d)/g, '$1');
714
+ }
715
+
716
+ module.exports = format_date_ymd;
717
+
718
+
719
+ /***/ }),
720
+
721
+ /***/ "./src/format_error_report.js":
722
+ /*!************************************!*\
723
+ !*** ./src/format_error_report.js ***!
724
+ \************************************/
725
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
726
+
727
+ const json_stringify_safe = __webpack_require__(/*! ./json_stringify_safe */ "./src/json_stringify_safe.js");
728
+
729
+ function format_error_report(error)
730
+ {
731
+ if (!error) {
732
+ return json_stringify_safe({error: error === undefined ? '---undefined---' : error});
733
+ }
734
+
735
+ if (error.response?.status && error.response?.statusText && error.response?.config) {
736
+ return fm_axios_response(error);
737
+ }
738
+
739
+ if (error.config) {
740
+ return fm_axios_config(error);
741
+ }
742
+
743
+ return json_stringify_safe({
744
+ code: error.code,
745
+ name: error.name,
746
+ message: error.message ?? 'n/a',
747
+ stack: error.stack && error.stack.split(/\n\s*/)
748
+ }, null, 4);
749
+ }
750
+
751
+ function fm_axios_response(error)
752
+ {
753
+ return `
754
+ ${error.message ?? 'n/a'}
755
+
756
+ --- REQUEST ---
757
+
758
+ ${(error.response.config.method||'').toUpperCase()} ${error.response.config.url}
759
+
760
+ ${JSON.stringify(error.response.config.headers||{}, null, 4).slice(1, -1).replace(/^\s+|,$/mg, '').trim()}
761
+
762
+ --- RESPONSE ---
763
+
764
+ ${error.response.status} ${error.response.statusText}
765
+
766
+ ${(error.response.data.toString()||'').slice(0, 10240) || 'n/a'}
767
+
768
+ --- STACK ---
769
+
770
+ ${error.stack ? error.stack.split(/\\n\\s*/) : 'n/a'}
771
+ `.trimStart();
772
+ }
773
+
774
+ function fm_axios_config(error)
775
+ {
776
+ return `
777
+ ${error.message ?? 'n/a'}
778
+
779
+ --- REQUEST ---
780
+
781
+ ${(error.config.method||'').toUpperCase()} ${error.config.url}
782
+
783
+ ${JSON.stringify(error.config.headers||{}, null, 4).slice(1, -1).replace(/^\s+|,$/mg, '').trim()}
784
+
785
+ --- STACK ---
786
+
787
+ ${error.stack ? error.stack.split(/\\n\\s*/) : 'n/a'}
788
+ `.trimStart();
789
+ }
790
+
791
+ module.exports = format_error_report;
792
+
793
+
794
+ /***/ }),
795
+
796
+ /***/ "./src/format_hrtime.js":
797
+ /*!******************************!*\
798
+ !*** ./src/format_hrtime.js ***!
799
+ \******************************/
800
+ /***/ ((module) => {
801
+
802
+ /**
803
+ * Return a human-readable representation of hrtime (the return value from `process.hrtime(hrtime0)`).
804
+ */
805
+ function format_hrtime(hrtime, digits = 6)
806
+ {
807
+ const [u, v] = hrtime; // process.hrtime(hrtime0)
808
+ return (u + v/1E9).toFixed(digits) + 's';
809
+ }
810
+
811
+ module.exports = format_hrtime;
812
+
813
+
814
+ /***/ }),
815
+
816
+ /***/ "./src/format_kilo.js":
817
+ /*!****************************!*\
818
+ !*** ./src/format_kilo.js ***!
819
+ \****************************/
820
+ /***/ ((module) => {
821
+
822
+ function format_kilo(num)
823
+ {
824
+ const sizes = ['', 'K', 'M', 'G', 'T', 'P'];
825
+ if (typeof num !== 'number' || Number.isNaN(num)) {
826
+ return 'n/a';
827
+ }
828
+ if (!num) {
829
+ return '0';
830
+ }
831
+ if (num < 1000) {
832
+ return num.toFixed(0);
833
+ }
834
+ const i = parseInt(Math.floor(Math.log(num) / Math.log(1000)), 10);
835
+ return `${(num / (1000 ** i)).toFixed(2)}${sizes[i]}`;
836
+ }
837
+
838
+ module.exports = format_kilo;
839
+
840
+
841
+ /***/ }),
842
+
843
+ /***/ "./src/format_ms.js":
844
+ /*!**************************!*\
845
+ !*** ./src/format_ms.js ***!
846
+ \**************************/
847
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
848
+
849
+ const factorize_ms = __webpack_require__(/*! ./factorize_ms */ "./src/factorize_ms.js");
850
+
851
+ /**
852
+ * Format milliseconds
853
+ */
854
+ function format_ms(ms)
855
+ {
856
+ if (!ms) {
857
+ ms = 0;
858
+ }
859
+
860
+ // 00:05
861
+ const [h, m, s] = factorize_ms(ms);
862
+ if (h) {
863
+ return `0${h}:0${m}:0${s}`.replace(/0+(?=\d\d)/g, '');
864
+ }
865
+ return `0${m}:0${s}`.replace(/0+(?=\d\d)/g, '');
866
+ }
867
+
868
+ module.exports = format_ms;
869
+
870
+
871
+ /***/ }),
872
+
873
+ /***/ "./src/format_ms2.js":
874
+ /*!***************************!*\
875
+ !*** ./src/format_ms2.js ***!
876
+ \***************************/
877
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
878
+
879
+ const factorize_ms = __webpack_require__(/*! ./factorize_ms */ "./src/factorize_ms.js");
880
+
881
+ /**
882
+ * Format milliseconds
883
+ */
884
+ function format_ms2(ms)
885
+ {
886
+ if (!ms) {
887
+ ms = 0;
888
+ }
889
+
890
+ // 00:05.45
891
+ const [h, m, s, xx] = factorize_ms(ms);
892
+ if (h) {
893
+ return `0${h}:0${m}:0${s}.0${Math.round(xx/10)}`.replace(/0+(?=\d\d)/g, '');
894
+ }
895
+ return `0${m}:0${s}.0${Math.round(xx/10)}`.replace(/0+(?=\d\d)/g, '');
896
+ }
897
+
898
+ module.exports = format_ms2;
899
+
900
+
901
+ /***/ }),
902
+
903
+ /***/ "./src/format_ms3.js":
904
+ /*!***************************!*\
905
+ !*** ./src/format_ms3.js ***!
906
+ \***************************/
907
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
908
+
909
+ const factorize_ms = __webpack_require__(/*! ./factorize_ms */ "./src/factorize_ms.js");
910
+
911
+ /**
912
+ * Format milliseconds
913
+ */
914
+ function format_ms3(ms)
915
+ {
916
+ if (!ms) {
917
+ ms = 0;
918
+ }
919
+
920
+ // 00:05.445
921
+ const [h, m, s, xx] = factorize_ms(ms);
922
+ if (h) {
923
+ return `0${h}:0${m}:0${s}.00${xx}`.replace(/0+(?=\d\d+[:.]|\d\d\d)/g, '');
924
+ }
925
+ return `0${m}:0${s}.00${xx}`.replace(/0+(?=\d\d+[:.]|\d\d\d)/g, '')
926
+ }
927
+
928
+ module.exports = format_ms3;
929
+
930
+
931
+ /***/ }),
932
+
933
+ /***/ "./src/format_percents.js":
934
+ /*!********************************!*\
935
+ !*** ./src/format_percents.js ***!
936
+ \********************************/
937
+ /***/ ((module) => {
938
+
939
+ function format_percents(v)
940
+ {
941
+ return (v*100).toFixed(2).replace(/^(0|100).00$/, '$1') + '%';
942
+ }
943
+
944
+ module.exports = format_percents;
945
+
946
+
947
+ /***/ }),
948
+
949
+ /***/ "./src/format_progress_bytes.js":
950
+ /*!**************************************!*\
951
+ !*** ./src/format_progress_bytes.js ***!
952
+ \**************************************/
953
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
954
+
955
+ const format_bytes = __webpack_require__(/*! ./format_bytes */ "./src/format_bytes.js");
956
+ const format_percents = __webpack_require__(/*! ./format_percents */ "./src/format_percents.js");
957
+ const format_seconds = __webpack_require__(/*! ./format_seconds */ "./src/format_seconds.js");
958
+ const is_number_gt = __webpack_require__(/*! ./is_number_gt */ "./src/is_number_gt.js");
959
+
960
+ function format_progress_bytes({percents, total, done, rate, eta, duration})
961
+ {
962
+ const bps = is_number_gt(rate, 0) ? `${format_bytes(rate)}/s` : '~';
963
+ if (done > total) {
964
+ return `${format_bytes(done)} at ${bps} duration=${format_seconds(duration)}`;
965
+ }
966
+ if (is_number_gt(total, 0)) {
967
+ const eta_str = is_number_gt(eta, 0) ? format_seconds(eta) : '~';
968
+ return `${format_percents(percents)} | ${format_bytes(done)} of ${format_bytes(total)} at ${bps} ETA ${eta_str} duration=${format_seconds(duration)}`;
969
+ }
970
+ if (is_number_gt(done, 0)) {
971
+ return `${format_bytes(done)} of ~ at ${bps} duration=${format_seconds(duration)}`;
972
+ }
973
+ if (is_number_gt(duration, 0)) {
974
+ return `~ duration=${format_seconds(duration)}`;
975
+ }
976
+ return '~';
977
+ }
978
+
979
+ module.exports = format_progress_bytes;
980
+
981
+
982
+ /***/ }),
983
+
984
+ /***/ "./src/format_progress_kilo.js":
985
+ /*!*************************************!*\
986
+ !*** ./src/format_progress_kilo.js ***!
987
+ \*************************************/
988
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
989
+
990
+ const format_kilo = __webpack_require__(/*! ./format_kilo */ "./src/format_kilo.js");
991
+ const format_percents = __webpack_require__(/*! ./format_percents */ "./src/format_percents.js");
992
+ const format_seconds = __webpack_require__(/*! ./format_seconds */ "./src/format_seconds.js");
993
+ const is_number_gt = __webpack_require__(/*! ./is_number_gt */ "./src/is_number_gt.js");
994
+
995
+ function format_progress_kilo({percents, total, done, rate, eta, duration})
996
+ {
997
+ const speed = is_number_gt(rate, 0) ? `${format_kilo(rate)}/s` : '~';
998
+ if (done > total) {
999
+ return `${format_kilo(done)} at ${speed} duration=${format_seconds(duration)}`;
1000
+ }
1001
+ if (is_number_gt(total, 0)) {
1002
+ const eta_str = is_number_gt(eta, 0) ? format_seconds(eta) : '~';
1003
+ return `${format_percents(percents)} | ${format_kilo(done)} of ${format_kilo(total)} at ${speed} ETA ${eta_str} duration=${format_seconds(duration)}`;
1004
+ }
1005
+ if (is_number_gt(done, 0)) {
1006
+ return `${format_kilo(done)} of ~ at ${speed} duration=${format_seconds(duration)}`;
1007
+ }
1008
+ if (is_number_gt(duration, 0)) {
1009
+ return `~ duration=${format_seconds(duration)}`;
1010
+ }
1011
+ return '~';
1012
+ }
1013
+
1014
+ module.exports = format_progress_kilo;
1015
+
1016
+
1017
+ /***/ }),
1018
+
1019
+ /***/ "./src/format_seconds.js":
1020
+ /*!*******************************!*\
1021
+ !*** ./src/format_seconds.js ***!
1022
+ \*******************************/
1023
+ /***/ ((module) => {
1024
+
1025
+ function format_seconds(seconds)
1026
+ {
1027
+ const v = Math.abs(Math.trunc(seconds));
1028
+ const hh = Math.floor(v / 60 / 60);
1029
+ const mm = Math.floor(v / 60) % 60;
1030
+ const ss = v % 60;
1031
+ const tmp = `0${hh}:0${mm}:0${ss}`.replace(/0(\d\d)/g, '$1');
1032
+ return (seconds <= -1) ? ('-' + tmp) : tmp;
1033
+ }
1034
+
1035
+ module.exports = format_seconds;
1036
+
1037
+
1038
+ /***/ }),
1039
+
1040
+ /***/ "./src/format_thousands.js":
1041
+ /*!*********************************!*\
1042
+ !*** ./src/format_thousands.js ***!
1043
+ \*********************************/
1044
+ /***/ ((module) => {
1045
+
1046
+ // https://stackoverflow.com/a/2901298
1047
+ function format_thousands(x)
1048
+ {
1049
+ return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ',');
1050
+ }
1051
+
1052
+ module.exports = format_thousands;
1053
+
1054
+
574
1055
  /***/ }),
575
1056
 
576
1057
  /***/ "./src/http_delete.js":
@@ -873,6 +1354,158 @@ function ignore()
873
1354
  module.exports = ignore;
874
1355
 
875
1356
 
1357
+ /***/ }),
1358
+
1359
+ /***/ "./src/is_number.js":
1360
+ /*!**************************!*\
1361
+ !*** ./src/is_number.js ***!
1362
+ \**************************/
1363
+ /***/ ((module) => {
1364
+
1365
+ function is_number(value)
1366
+ {
1367
+ return (typeof value === 'number') && isFinite(value);
1368
+ }
1369
+
1370
+ module.exports = is_number;
1371
+
1372
+
1373
+ /***/ }),
1374
+
1375
+ /***/ "./src/is_number_gt.js":
1376
+ /*!*****************************!*\
1377
+ !*** ./src/is_number_gt.js ***!
1378
+ \*****************************/
1379
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1380
+
1381
+ const is_number = __webpack_require__(/*! ./is_number */ "./src/is_number.js");
1382
+
1383
+ function is_number_gt(value, min)
1384
+ {
1385
+ return is_number(value) && value > min;
1386
+ }
1387
+
1388
+ module.exports = is_number_gt;
1389
+
1390
+
1391
+ /***/ }),
1392
+
1393
+ /***/ "./src/json_stringify_safe.js":
1394
+ /*!************************************!*\
1395
+ !*** ./src/json_stringify_safe.js ***!
1396
+ \************************************/
1397
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1398
+
1399
+ const json_stringify_safe = __webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js");
1400
+
1401
+ module.exports = json_stringify_safe;
1402
+
1403
+
1404
+ /***/ }),
1405
+
1406
+ /***/ "./src/plural.js":
1407
+ /*!***********************!*\
1408
+ !*** ./src/plural.js ***!
1409
+ \***********************/
1410
+ /***/ ((module) => {
1411
+
1412
+ function plural(n, apple, apples)
1413
+ {
1414
+ return (n % 10 === 1 && n % 100 !== 11) ? apple.split('#').join(n) : apples.split('#').join(n);
1415
+ }
1416
+
1417
+ module.exports = plural;
1418
+
1419
+
1420
+ /***/ }),
1421
+
1422
+ /***/ "./src/random_int.js":
1423
+ /*!***************************!*\
1424
+ !*** ./src/random_int.js ***!
1425
+ \***************************/
1426
+ /***/ ((module) => {
1427
+
1428
+ function random_int(min, max)
1429
+ {
1430
+ return Math.floor(Math.random()*(max - min + 1) + min);
1431
+ }
1432
+
1433
+ module.exports = random_int;
1434
+
1435
+
1436
+ /***/ }),
1437
+
1438
+ /***/ "./src/urlmod.js":
1439
+ /*!***********************!*\
1440
+ !*** ./src/urlmod.js ***!
1441
+ \***********************/
1442
+ /***/ ((module) => {
1443
+
1444
+ /**
1445
+ * Set, change, or remove query string parameters.
1446
+ *
1447
+ * urlmod('', {a: 1}) '?a=1' set
1448
+ * urlmod('?a=1', {a: 2}) '?a=2' change
1449
+ * urlmod('?a=1', {a: null}) '' remove
1450
+ */
1451
+ function urlmod(url, params)
1452
+ {
1453
+ const tmp_url = new URL(url||'', 'xxx://___base___/');
1454
+ const tmp_search = tmp_url.searchParams;
1455
+ Object.entries(params || {}).forEach(function ([key, value]) {
1456
+ switch (value) {
1457
+ case null:
1458
+ case undefined:
1459
+ tmp_search.delete(key);
1460
+ break;
1461
+ case true:
1462
+ tmp_search.set(key, 1);
1463
+ break;
1464
+ case false:
1465
+ tmp_search.set(key, 0);
1466
+ break;
1467
+ default:
1468
+ tmp_search.set(key, value);
1469
+ break;
1470
+ }
1471
+ });
1472
+ if (url && url[0] === '/') {
1473
+ return tmp_url.toString().replace(/^xxx:\/\/___base___/, '');
1474
+ }
1475
+ return tmp_url.toString().replace(/^xxx:\/\/___base___\//, '');
1476
+ }
1477
+
1478
+ module.exports = urlmod;
1479
+
1480
+
1481
+ /***/ }),
1482
+
1483
+ /***/ "./src/waitcb.js":
1484
+ /*!***********************!*\
1485
+ !*** ./src/waitcb.js ***!
1486
+ \***********************/
1487
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1488
+
1489
+ const Promise = __webpack_require__(/*! bluebird */ "bluebird");
1490
+
1491
+ /**
1492
+ * Wait for a Node-like function to finish (which will call `callback`
1493
+ * with 2 arguments: `error` and `value`).
1494
+ *
1495
+ * await waitcb(cb => fs.writeFile('a', 'hello\n', cb));
1496
+ */
1497
+ function waitcb(fn)
1498
+ {
1499
+ return new Promise(function (resolve, reject) {
1500
+ fn(function (error, out) {
1501
+ error ? reject(error) : resolve(out);
1502
+ });
1503
+ });
1504
+ }
1505
+
1506
+ module.exports = waitcb;
1507
+
1508
+
876
1509
  /***/ }),
877
1510
 
878
1511
  /***/ "axios":
@@ -886,6 +1519,17 @@ module.exports = axios;
886
1519
 
887
1520
  /***/ }),
888
1521
 
1522
+ /***/ "bluebird":
1523
+ /*!**************************!*\
1524
+ !*** external "Promise" ***!
1525
+ \**************************/
1526
+ /***/ ((module) => {
1527
+
1528
+ "use strict";
1529
+ module.exports = Promise;
1530
+
1531
+ /***/ }),
1532
+
889
1533
  /***/ "form-data":
890
1534
  /*!***************************!*\
891
1535
  !*** external "FormData" ***!
@@ -930,6 +1574,7 @@ module.exports = FormData;
930
1574
  /******/ })();
931
1575
  /******/
932
1576
  /************************************************************************/
1577
+ var __webpack_exports__ = {};
933
1578
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
934
1579
  (() => {
935
1580
  /*!******************************!*\
@@ -937,7 +1582,7 @@ module.exports = FormData;
937
1582
  \******************************/
938
1583
  // https://github.com/webpack/webpack/issues/625
939
1584
  // https://webpack.js.org/guides/dependency-management/#require-context
940
- const require_tmp = __webpack_require__("./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore).*(?<%21\\.test)\\.js$");
1585
+ const require_tmp = __webpack_require__("./src sync recursive \\b(array%7Cdate%7Chttp_delete%7Chttp_get_blob%7Chttp_get_buffer%7Chttp_get_json%7Chttp_get_utf8%7Chttp_head%7Chttp_patch_json%7Chttp_post_json%7Chttp_post_multipart%7Chttp_put_buffer%7Chttp_put_json%7Chttp_put_utf8%7Cidentity%7Cignore%7Cformat%7Cplural%7Crandom_int%7Curlmod%7Cwaitcb)[^/]*(?<%21\\.test)\\.js$");
941
1586
  require_tmp.keys().forEach(function (key) {
942
1587
  const [, basename] = key.match(/([^/]+)\.js$/);
943
1588
  window[basename] = require_tmp(key);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "3.63.0",
5
+ "version": "3.63.1",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "unpkg": "dist/browser.js",
8
8
  "jsdelivr": "dist/browser.js",
@@ -1,6 +1,6 @@
1
1
  // https://github.com/webpack/webpack/issues/625
2
2
  // https://webpack.js.org/guides/dependency-management/#require-context
3
- const require_tmp = require.context('..', true, /\b(array|date|http_delete|http_get_blob|http_get_buffer|http_get_json|http_get_utf8|http_head|http_patch_json|http_post_json|http_post_multipart|http_put_buffer|http_put_json|http_put_utf8|identity|ignore).*(?<!\.test)\.js$/);
3
+ const require_tmp = require.context('..', true, /\b(array|date|http_delete|http_get_blob|http_get_buffer|http_get_json|http_get_utf8|http_head|http_patch_json|http_post_json|http_post_multipart|http_put_buffer|http_put_json|http_put_utf8|identity|ignore|format|plural|random_int|urlmod|waitcb)[^/]*(?<!\.test)\.js$/);
4
4
  require_tmp.keys().forEach(function (key) {
5
5
  const [, basename] = key.match(/([^/]+)\.js$/);
6
6
  window[basename] = require_tmp(key);