@putkoff/abstract-utilities 1.0.113 → 1.0.124

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.
Files changed (207) hide show
  1. package/dist/cjs/client.js +1 -11
  2. package/dist/cjs/client.js.map +1 -1
  3. package/dist/cjs/functions.js +4 -14
  4. package/dist/cjs/functions.js.map +1 -1
  5. package/dist/cjs/index.js +4 -14
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/{print_utils-DzyRoj6m.js → print_utils-DhPs0s0W.js} +6 -16
  8. package/dist/cjs/print_utils-DhPs0s0W.js.map +1 -0
  9. package/dist/cjs/safe_storage-B6MYZDKg.js +941 -0
  10. package/dist/cjs/safe_storage-B6MYZDKg.js.map +1 -0
  11. package/dist/esm/client.js +1 -11
  12. package/dist/esm/client.js.map +1 -1
  13. package/dist/esm/functions.js +2 -12
  14. package/dist/esm/functions.js.map +1 -1
  15. package/dist/esm/index.js +2 -12
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/{print_utils-qqcMhSul.js → print_utils-gTxtZBM7.js} +2 -12
  18. package/dist/esm/print_utils-gTxtZBM7.js.map +1 -0
  19. package/dist/esm/safe_storage-D4QfcTw0.js +897 -0
  20. package/dist/esm/safe_storage-D4QfcTw0.js.map +1 -0
  21. package/dist/types/client/auth/index.d.ts +1 -1
  22. package/dist/types/client/auth/src/index.d.ts +1 -1
  23. package/dist/types/client/fetch/src/fetch_auth.d.ts +1 -1
  24. package/dist/types/client/fetch/src/index.d.ts +1 -1
  25. package/dist/types/client/index.d.ts +2 -2
  26. package/dist/types/client/ui_utils/index.d.ts +1 -1
  27. package/dist/types/client/ui_utils/src/index.d.ts +4 -4
  28. package/dist/types/functions/auth_utils/imports.d.ts +2 -2
  29. package/dist/types/functions/auth_utils/index.d.ts +1 -1
  30. package/dist/types/functions/auth_utils/src/index.d.ts +1 -1
  31. package/dist/types/functions/auth_utils/src/jwt_core.d.ts +1 -1
  32. package/dist/types/functions/auth_utils/src/token_utils (Copy).d.ts +1 -1
  33. package/dist/types/functions/auth_utils/src/token_utils.d.ts +1 -1
  34. package/dist/types/functions/config_utils/imports.d.ts +3 -3
  35. package/dist/types/functions/config_utils/index.d.ts +1 -1
  36. package/dist/types/functions/config_utils/src/config_utils.d.ts +1 -1
  37. package/dist/types/functions/config_utils/src/index.d.ts +1 -1
  38. package/dist/types/functions/constants_utils/index.d.ts +1 -1
  39. package/dist/types/functions/constants_utils/src/index.d.ts +1 -1
  40. package/dist/types/functions/env_utils/imports.d.ts +1 -1
  41. package/dist/types/functions/env_utils/index.d.ts +1 -1
  42. package/dist/types/functions/env_utils/src/index.d.ts +1 -1
  43. package/dist/types/functions/fetch_utils/imports.d.ts +2 -2
  44. package/dist/types/functions/fetch_utils/index.d.ts +1 -1
  45. package/dist/types/functions/fetch_utils/src/index.d.ts +3 -3
  46. package/dist/types/functions/fetch_utils/src/utils.d.ts +1 -1
  47. package/dist/types/functions/inspect_utils/index.d.ts +2 -2
  48. package/dist/types/functions/inspect_utils/src/index.d.ts +1 -1
  49. package/dist/types/functions/math_utils/conversions.d.ts +1 -1
  50. package/dist/types/functions/math_utils/index.d.ts +6 -6
  51. package/dist/types/functions/path_utils/imports.d.ts +2 -2
  52. package/dist/types/functions/path_utils/index.d.ts +1 -1
  53. package/dist/types/functions/path_utils/src/index.d.ts +6 -6
  54. package/dist/types/functions/print_utils/imports.d.ts +1 -1
  55. package/dist/types/functions/print_utils/index.d.ts +1 -1
  56. package/dist/types/functions/print_utils/src/index.d.ts +1 -1
  57. package/dist/types/functions/read_utils/imports.d.ts +1 -1
  58. package/dist/types/functions/read_utils/index.d.ts +1 -1
  59. package/dist/types/functions/read_utils/src/index.d.ts +3 -3
  60. package/dist/types/functions/rndm_utils/imports.d.ts +0 -1
  61. package/dist/types/functions/rndm_utils/index.d.ts +1 -1
  62. package/dist/types/functions/rndm_utils/src/index.d.ts +1 -1
  63. package/dist/types/functions/safe_utils/imports.d.ts +1 -1
  64. package/dist/types/functions/safe_utils/index.d.ts +1 -1
  65. package/dist/types/functions/safe_utils/src/index.d.ts +4 -4
  66. package/dist/types/functions/size_utils/index.d.ts +1 -1
  67. package/dist/types/functions/size_utils/src/index.d.ts +1 -1
  68. package/dist/types/functions/string_utils/index.d.ts +1 -1
  69. package/dist/types/functions/string_utils/src/index.d.ts +2 -2
  70. package/dist/types/functions/type_utils/imports.d.ts +0 -1
  71. package/dist/types/functions/type_utils/index.d.ts +1 -1
  72. package/dist/types/functions/type_utils/src/imports.d.ts +0 -1
  73. package/dist/types/functions/type_utils/src/index.d.ts +6 -6
  74. package/dist/types/functions/variable_utils/imports.d.ts +1 -1
  75. package/dist/types/functions/variable_utils/index.d.ts +1 -1
  76. package/dist/types/functions/variable_utils/src/index.d.ts +1 -1
  77. package/dist/types/index.d.ts +2 -2
  78. package/dist/types/server/index.d.ts +1 -1
  79. package/dist/types/server/src/index.d.ts +1 -1
  80. package/dist/types/types/index.d.ts +1 -1
  81. package/dist/types/types/path-browserify.d.ts +2 -3
  82. package/dist/types/types/src/index.d.ts +4 -4
  83. package/dist/types/utils/imports.d.ts +1 -1
  84. package/dist/types/utils/index.d.ts +1 -1
  85. package/dist/types/utils/src/index.d.ts +2 -2
  86. package/package.json +2 -2
  87. package/dist/cjs/print_utils-DzyRoj6m.js.map +0 -1
  88. package/dist/cjs/safe_storage-CJgWghnh.js +0 -15986
  89. package/dist/cjs/safe_storage-CJgWghnh.js.map +0 -1
  90. package/dist/esm/print_utils-qqcMhSul.js.map +0 -1
  91. package/dist/esm/safe_storage-CMuv35Vo.js +0 -15941
  92. package/dist/esm/safe_storage-CMuv35Vo.js.map +0 -1
  93. package/dist/types/client/auth/index.js +0 -3
  94. package/dist/types/client/auth/src/index.js +0 -3
  95. package/dist/types/client/auth/src/token_client.js +0 -73
  96. package/dist/types/client/fetch/src/fetch_auth.js +0 -26
  97. package/dist/types/client/fetch/src/index.js +0 -2
  98. package/dist/types/client/index.js +0 -4
  99. package/dist/types/client/ui_utils/index.js +0 -2
  100. package/dist/types/client/ui_utils/src/button.js +0 -34
  101. package/dist/types/client/ui_utils/src/checkbox.js +0 -18
  102. package/dist/types/client/ui_utils/src/index.js +0 -4
  103. package/dist/types/client/ui_utils/src/input.js +0 -18
  104. package/dist/types/client/ui_utils/src/spinner.js +0 -5
  105. package/dist/types/functions/auth_utils/imports.js +0 -1
  106. package/dist/types/functions/auth_utils/index.js +0 -1
  107. package/dist/types/functions/auth_utils/src/index.js +0 -1
  108. package/dist/types/functions/auth_utils/src/jwt_core.js +0 -25
  109. package/dist/types/functions/auth_utils/src/token_utils (Copy).js +0 -25
  110. package/dist/types/functions/auth_utils/src/token_utils.js +0 -105
  111. package/dist/types/functions/config_utils/imports.js +0 -2
  112. package/dist/types/functions/config_utils/index.js +0 -1
  113. package/dist/types/functions/config_utils/src/config_utils.js +0 -83
  114. package/dist/types/functions/config_utils/src/index.js +0 -1
  115. package/dist/types/functions/constants_utils/index.js +0 -1
  116. package/dist/types/functions/constants_utils/src/constants.js +0 -7
  117. package/dist/types/functions/constants_utils/src/index.js +0 -1
  118. package/dist/types/functions/env_utils/imports.js +0 -1
  119. package/dist/types/functions/env_utils/index.js +0 -1
  120. package/dist/types/functions/env_utils/src/index.js +0 -1
  121. package/dist/types/functions/env_utils/src/window_utils.js +0 -47
  122. package/dist/types/functions/fetch_utils/imports.js +0 -1
  123. package/dist/types/functions/fetch_utils/index.js +0 -1
  124. package/dist/types/functions/fetch_utils/src/fetch_utils.js +0 -70
  125. package/dist/types/functions/fetch_utils/src/index.js +0 -3
  126. package/dist/types/functions/fetch_utils/src/url_utils.js +0 -86
  127. package/dist/types/functions/fetch_utils/src/utils.js +0 -102
  128. package/dist/types/functions/index.js +0 -17
  129. package/dist/types/functions/inspect_utils/imports.js +0 -1
  130. package/dist/types/functions/inspect_utils/index.js +0 -2
  131. package/dist/types/functions/inspect_utils/src/caller_utils.js +0 -28
  132. package/dist/types/functions/inspect_utils/src/index.js +0 -1
  133. package/dist/types/functions/math_utils/bigint_utils.js +0 -36
  134. package/dist/types/functions/math_utils/constants.js +0 -37
  135. package/dist/types/functions/math_utils/conversions.js +0 -129
  136. package/dist/types/functions/math_utils/index.js +0 -6
  137. package/dist/types/functions/math_utils/safe_math.js +0 -35
  138. package/dist/types/functions/math_utils/scaleInterfaces.js +0 -3
  139. package/dist/types/functions/math_utils/time_utils.js +0 -4
  140. package/dist/types/functions/path_utils/imports.js +0 -27
  141. package/dist/types/functions/path_utils/index.js +0 -1
  142. package/dist/types/functions/path_utils/src/base_dirs.js +0 -17
  143. package/dist/types/functions/path_utils/src/function_dirs.js +0 -42
  144. package/dist/types/functions/path_utils/src/index.js +0 -6
  145. package/dist/types/functions/path_utils/src/misc_dirs.js +0 -15
  146. package/dist/types/functions/path_utils/src/path_utils.js +0 -160
  147. package/dist/types/functions/path_utils/src/paths.js +0 -12
  148. package/dist/types/functions/path_utils/src/src_dirs.js +0 -25
  149. package/dist/types/functions/print_utils/imports.js +0 -1
  150. package/dist/types/functions/print_utils/index.js +0 -1
  151. package/dist/types/functions/print_utils/src/index.js +0 -1
  152. package/dist/types/functions/print_utils/src/print_utils.js +0 -14
  153. package/dist/types/functions/read_utils/imports.js +0 -1
  154. package/dist/types/functions/read_utils/index.js +0 -1
  155. package/dist/types/functions/read_utils/src/index.js +0 -3
  156. package/dist/types/functions/read_utils/src/readJsonFile.browser.js +0 -26
  157. package/dist/types/functions/read_utils/src/readJsonFile.js +0 -35
  158. package/dist/types/functions/read_utils/src/readJsonFile.node.js +0 -13
  159. package/dist/types/functions/rndm_utils/imports.js +0 -1
  160. package/dist/types/functions/rndm_utils/index.js +0 -1
  161. package/dist/types/functions/rndm_utils/src/index.js +0 -1
  162. package/dist/types/functions/rndm_utils/src/utils.js +0 -12
  163. package/dist/types/functions/safe_utils/imports.js +0 -1
  164. package/dist/types/functions/safe_utils/index.js +0 -1
  165. package/dist/types/functions/safe_utils/src/index.js +0 -4
  166. package/dist/types/functions/safe_utils/src/safe_document.js +0 -12
  167. package/dist/types/functions/safe_utils/src/safe_globals.js +0 -14
  168. package/dist/types/functions/safe_utils/src/safe_storage.js +0 -50
  169. package/dist/types/functions/safe_utils/src/safe_window.js +0 -42
  170. package/dist/types/functions/size_utils/index.js +0 -1
  171. package/dist/types/functions/size_utils/src/index.js +0 -1
  172. package/dist/types/functions/size_utils/src/sizeUtils.js +0 -44
  173. package/dist/types/functions/string_utils/index.js +0 -1
  174. package/dist/types/functions/string_utils/src/index.js +0 -2
  175. package/dist/types/functions/string_utils/src/quote_utils.js +0 -17
  176. package/dist/types/functions/string_utils/src/string_utils.js +0 -186
  177. package/dist/types/functions/type_utils/imports.js +0 -1
  178. package/dist/types/functions/type_utils/index.js +0 -1
  179. package/dist/types/functions/type_utils/src/clean_utils.js +0 -38
  180. package/dist/types/functions/type_utils/src/ensure_utils.js +0 -84
  181. package/dist/types/functions/type_utils/src/imports.js +0 -1
  182. package/dist/types/functions/type_utils/src/index.js +0 -6
  183. package/dist/types/functions/type_utils/src/json_utils.js +0 -93
  184. package/dist/types/functions/type_utils/src/list_utils.js +0 -83
  185. package/dist/types/functions/type_utils/src/mime_utils.js +0 -314
  186. package/dist/types/functions/type_utils/src/null_utils.js +0 -21
  187. package/dist/types/functions/type_utils/src/type_utils.js +0 -39
  188. package/dist/types/functions/variable_utils/imports.js +0 -1
  189. package/dist/types/functions/variable_utils/index.js +0 -1
  190. package/dist/types/functions/variable_utils/src/index.js +0 -1
  191. package/dist/types/functions/variable_utils/src/variable_utils.js +0 -34
  192. package/dist/types/index.js +0 -2
  193. package/dist/types/server/index.js +0 -2
  194. package/dist/types/server/src/index.js +0 -2
  195. package/dist/types/server/src/mime_utils.js +0 -314
  196. package/dist/types/types/index.js +0 -1
  197. package/dist/types/types/path-browserify.js +0 -1
  198. package/dist/types/types/src/Files.js +0 -1
  199. package/dist/types/types/src/index.js +0 -4
  200. package/dist/types/types/src/login.js +0 -1
  201. package/dist/types/types/src/logout.js +0 -1
  202. package/dist/types/types/src/utils.js +0 -1
  203. package/dist/types/utils/imports.js +0 -1
  204. package/dist/types/utils/index.js +0 -1
  205. package/dist/types/utils/src/Input.js +0 -2
  206. package/dist/types/utils/src/config.js +0 -27
  207. package/dist/types/utils/src/index.js +0 -2
@@ -1,160 +0,0 @@
1
- import * as path from 'path-browserify';
2
- import { eatOuter, eatInner, ensure_list } from './../imports';
3
- export function get_dirname(filePath) {
4
- if (!filePath)
5
- return '';
6
- return path.dirname(filePath);
7
- }
8
- export function get_basename(filePath) {
9
- if (!filePath)
10
- return '';
11
- return path.basename(filePath);
12
- }
13
- export function get_filename(filePath) {
14
- if (!filePath)
15
- return '';
16
- const ext = path.extname(filePath);
17
- return path.basename(filePath, ext);
18
- }
19
- export function get_extname(filePath) {
20
- if (!filePath)
21
- return '';
22
- return path.extname(filePath);
23
- }
24
- export function get_splitext(filePath) {
25
- if (!filePath)
26
- return { filename: '', extname: '' };
27
- const ext = path.extname(filePath);
28
- // Get the basename without the extension
29
- const filename = path.basename(filePath, ext);
30
- return { filename, ext };
31
- }
32
- /**
33
- * Returns the path of `targetPath` relative to `basePath`.
34
- * Normalizes separators for consistent web and server environments.
35
- *
36
- * @param basePath - The base directory you want to compare from.
37
- * @param targetPath - The full path of the file/directory.
38
- * @returns A normalized relative path (e.g., "subdir/file.txt").
39
- */
40
- export function get_relative_path(basePath, targetPath) {
41
- try {
42
- // Compute the relative path using Node's native path.relative
43
- let rel = path.relative(basePath, targetPath);
44
- // Normalize to POSIX-style slashes for consistency (especially on Windows)
45
- rel = rel.split(path.sep).join('/');
46
- // Avoid empty string (happens if both paths are identical)
47
- return rel || '.';
48
- }
49
- catch (err) {
50
- console.error(`[get_relative_path] Error computing relative path`, err);
51
- return targetPath;
52
- }
53
- }
54
- /**
55
- * Join multiple path segments — clean, predictable, bulletproof.
56
- *
57
- * Accepts ANYTHING that ensure_list can handle:
58
- * • 'a,b,c'
59
- * • ['a', 'b,c']
60
- * • 'a/b/c'
61
- * • '/a/', 'b//c'
62
- * • mixed arrays, comma strings, whatever
63
- *
64
- * Always returns a clean POSIX path string. Never a list.
65
- */
66
- export function make_path(...parts) {
67
- // Normalize incoming segments into a flat list
68
- const segments = ensure_list(parts).map(x => String(x));
69
- let out = "";
70
- for (let i = 0; i < segments.length; i++) {
71
- const seg = segments[i];
72
- // Normalize a segment:
73
- let cleaned = eatOuter(seg, "/"); // trim trailing slashes
74
- if (!cleaned)
75
- continue;
76
- if (out === "") {
77
- out = cleaned;
78
- }
79
- else {
80
- cleaned = eatInner(cleaned, "/"); // trim leading slashes
81
- out = `${out}/${cleaned}`;
82
- }
83
- }
84
- return out;
85
- }
86
- export function sanitizeFilename(filename) {
87
- return filename
88
- .toLowerCase()
89
- .replace(/\s+|-/g, '-') // Replace spaces and hyphens with single hyphen
90
- .replace(/_/g, '-') // Replace underscores with hyphens
91
- .replace(/[^a-z0-9-.]/g, '') // Remove all non-alphanumeric chars except hyphen and dot
92
- .replace(/-+/g, '-') // Collapse multiple hyphens into one
93
- .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
94
- }
95
- export function make_sanitized_path(...paths) {
96
- let real_path = '';
97
- for (let i = 0; i < paths.length; i++) {
98
- const sanitized = sanitizeFilename(eatOuter(paths[i], '/'));
99
- if (i === 0) {
100
- real_path = sanitized;
101
- }
102
- else if (sanitized) { // Only append if there's a non-empty segment
103
- real_path = `${real_path}/${sanitized}`;
104
- }
105
- }
106
- return real_path || '';
107
- }
108
- export function normalizeUrl(base, p) {
109
- if (!p)
110
- return base;
111
- const cleanBase = base.replace(/\/+$/, ''); // regex literal
112
- const cleanPath = p.replace(/^\/+/, '');
113
- // collapse multiple “//” into one, but keep the “://” after protocol
114
- return `${cleanBase}/${cleanPath}`.replace(/([^:])\/{2,}/g, '$1/');
115
- }
116
- export function pathjoin(...parts) {
117
- return make_path(...parts);
118
- }
119
- export function pathJoin(...parts) {
120
- return make_path(...parts);
121
- }
122
- export function makepath(...parts) {
123
- return make_path(...parts);
124
- }
125
- export function makePath(...parts) {
126
- return make_path(...parts);
127
- }
128
- export function path_join(...parts) {
129
- return make_path(...parts);
130
- }
131
- export function getSplitext(filePath) {
132
- return get_splitext(filePath);
133
- }
134
- export function getsplitext(filePath) {
135
- return get_splitext(filePath);
136
- }
137
- export function getextname(filePath) {
138
- return get_extname(filePath);
139
- }
140
- export function getExtname(filePath) {
141
- return get_extname(filePath);
142
- }
143
- export function getfilename(filePath) {
144
- return get_filename(filePath);
145
- }
146
- export function getFilename(filePath) {
147
- return get_filename(filePath);
148
- }
149
- export function getbasename(filePath) {
150
- return get_basename(filePath);
151
- }
152
- export function getBasename(filePath) {
153
- return get_basename(filePath);
154
- }
155
- export function getdirname(filePath) {
156
- return get_dirname(filePath);
157
- }
158
- export function getDirname(filePath) {
159
- return get_dirname(filePath);
160
- }
@@ -1,12 +0,0 @@
1
- import { getAbsolutePath } from './../imports';
2
- import { get_dirname, make_path } from './path_utils';
3
- /**
4
- * Returns the absolute path of the current file.
5
- */
6
- export function getAbsDir() {
7
- return get_dirname(getAbsolutePath());
8
- }
9
- ;
10
- export function getAbsPath(subPath) {
11
- return make_path(getAbsDir(), subPath);
12
- }
@@ -1,25 +0,0 @@
1
- import { make_path, get_dirname } from './path_utils';
2
- import { getFunctionsDir } from './function_dirs';
3
- export function getSrcDir() {
4
- return get_dirname(getFunctionsDir());
5
- }
6
- ;
7
- export function geStaticDirectory() {
8
- return make_path(getSrcDir(), 'static');
9
- }
10
- ;
11
- export function getLibUtilsDirectory() {
12
- return make_path(getSrcDir(), 'lib');
13
- }
14
- export function getHooksUtilsDirectory() {
15
- return make_path(getSrcDir(), 'hooks');
16
- }
17
- ;
18
- export function getFunctionsUtilsDirectory() {
19
- return make_path(getSrcDir(), 'functions');
20
- }
21
- ;
22
- export function getComponentsUtilsDirectory() {
23
- return make_path(getSrcDir(), 'components');
24
- }
25
- ;
@@ -1 +0,0 @@
1
- export * from './../inspect_utils';
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1 +0,0 @@
1
- export * from './print_utils';
@@ -1,14 +0,0 @@
1
- import { getLastCaller, inspect } from './../imports';
2
- export function debugPrint(value, label = null) {
3
- const caller = getLastCaller();
4
- const header = label !== null && label !== void 0 ? label : (caller
5
- ? `${caller.functionName} @ ${caller.file}:${caller.line}`
6
- : "object");
7
- console.log(`\n🔍 ${header}`);
8
- console.log(inspect(value, {
9
- depth: null,
10
- colors: true,
11
- compact: false,
12
- maxArrayLength: null,
13
- }));
14
- }
@@ -1 +0,0 @@
1
- export { safeGlobalProp } from './../safe_utils';
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1,3 +0,0 @@
1
- export * from './readJsonFile.browser';
2
- export * from './readJsonFile.node';
3
- export * from './readJsonFile';
@@ -1,26 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { safeGlobalProp } from "./../imports";
11
- export function readJsonFileBrowser(url) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const fetchFn = safeGlobalProp("fetch");
14
- if (typeof fetchFn !== "function")
15
- return null;
16
- try {
17
- const res = yield fetchFn(url);
18
- if (!res.ok)
19
- return null;
20
- return (yield res.json());
21
- }
22
- catch (_a) {
23
- return null;
24
- }
25
- });
26
- }
@@ -1,35 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export function readJsonFile(relativeOrAbsolutePath) {
11
- return __awaiter(this, void 0, void 0, function* () {
12
- var _a;
13
- if (typeof process !== "undefined" && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
14
- const mod = yield import("./readJsonFile.node");
15
- return mod.readJsonFileNode(relativeOrAbsolutePath);
16
- }
17
- else {
18
- const mod = yield import("./readJsonFile.browser");
19
- return mod.readJsonFileBrowser(relativeOrAbsolutePath);
20
- }
21
- });
22
- }
23
- export function getConfigContent() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- try {
26
- // `readJsonFile` should throw if the file isn’t there or isn’t valid JSON
27
- const cfg = yield readJsonFile('./config.json');
28
- return cfg;
29
- }
30
- catch (_a) {
31
- // swallow errors & return null so callers can detect “no config”
32
- return null;
33
- }
34
- });
35
- }
@@ -1,13 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve, isAbsolute } from "node:path";
3
- export function readJsonFileNode(relativeOrAbsolutePath) {
4
- try {
5
- const filePath = isAbsolute(relativeOrAbsolutePath)
6
- ? relativeOrAbsolutePath
7
- : resolve(process.cwd(), relativeOrAbsolutePath);
8
- return JSON.parse(readFileSync(filePath, "utf8"));
9
- }
10
- catch (_a) {
11
- return null;
12
- }
13
- }
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1 +0,0 @@
1
- export * from './utils';
@@ -1,12 +0,0 @@
1
- // src/functions/rndm_utils/utils.ts
2
- export function alertit(obj = null) {
3
- let msg;
4
- try {
5
- msg = JSON.stringify(obj);
6
- }
7
- catch (_a) {
8
- // If JSON.stringify fails (circular refs, etc.), fall back to a simple string
9
- msg = String(obj);
10
- }
11
- alert(msg);
12
- }
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1,4 +0,0 @@
1
- export * from './safe_document';
2
- export * from './safe_storage';
3
- export * from './safe_globals';
4
- export * from './safe_window';
@@ -1,12 +0,0 @@
1
- export function getSafeDocument() {
2
- return typeof document !== 'undefined' ? document : undefined;
3
- }
4
- export function getDocumentProp(...keys) {
5
- let obj = getSafeDocument();
6
- for (const k of keys) {
7
- if (obj == null || typeof obj !== 'object')
8
- return undefined;
9
- obj = obj[k];
10
- }
11
- return obj;
12
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Safely walk `globalThis` (or window/document) by a chain of property names.
3
- * Returns `undefined` if any step is missing.
4
- */
5
- export function safeGlobalProp(...path) {
6
- let obj = globalThis;
7
- for (const key of path) {
8
- if (obj == null || typeof obj !== "object" || !(key in obj)) {
9
- return undefined;
10
- }
11
- obj = obj[key];
12
- }
13
- return obj;
14
- }
@@ -1,50 +0,0 @@
1
- import { safeGlobalProp } from './safe_globals';
2
- /**
3
- * Returns `window` if running in a browser, otherwise `undefined`.
4
- */
5
- export function getSafeLocalStorage() {
6
- if (typeof window === 'undefined')
7
- return undefined;
8
- try {
9
- return window.localStorage;
10
- }
11
- catch (_a) {
12
- return undefined; // e.g. Safari private-mode block
13
- }
14
- }
15
- /**
16
- * Call a Storage method by name, silencing any errors or missing storage.
17
- *
18
- * @param method One of the keys of the Storage interface: "getItem", "setItem", etc.
19
- * @param args The arguments you’d normally pass to that method.
20
- * @returns The method’s return value, or undefined if storage/method isn’t available.
21
- */
22
- export function callStorage(method, ...args) {
23
- const storage = getSafeLocalStorage();
24
- if (!storage)
25
- return undefined;
26
- const fn = storage[method];
27
- if (typeof fn !== 'function')
28
- return undefined;
29
- try {
30
- return fn.apply(storage, args);
31
- }
32
- catch (_a) {
33
- return undefined;
34
- }
35
- }
36
- /**
37
- * Safely call storage methods (`localStorage` or `sessionStorage`) without blowing up.
38
- * Returns `undefined` on any error.
39
- */
40
- export function safeStorage(storageName, method, ...args) {
41
- try {
42
- const store = safeGlobalProp(storageName);
43
- if (!store || typeof store[method] !== "function")
44
- return undefined;
45
- return store[method](...args);
46
- }
47
- catch (_a) {
48
- return undefined;
49
- }
50
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Returns the global window object if it exists, otherwise undefined.
3
- */
4
- export function getSafeWindow() {
5
- return typeof window !== 'undefined' ? window : undefined;
6
- }
7
- /**
8
- * Safely call a method on window by name.
9
- *
10
- * @param method The Window method to call (e.g. "alert", "open", etc.).
11
- * @param args Arguments to pass to that method.
12
- * @returns The method’s return value, or undefined if
13
- * window/method isn’t available or throws.
14
- */
15
- export function callWindowMethod(method, ...args) {
16
- const w = getSafeWindow();
17
- if (!w)
18
- return undefined;
19
- const fn = w[method];
20
- if (typeof fn !== 'function')
21
- return undefined;
22
- try {
23
- // cast to any so TS doesn’t complain about apply/invoke
24
- return fn(...args);
25
- }
26
- catch (_a) {
27
- return undefined;
28
- }
29
- }
30
- /** implementation */
31
- export function getWindowProp(...keys) {
32
- let obj = getSafeWindow();
33
- for (const k of keys) {
34
- if (obj == null || typeof obj !== 'object')
35
- return undefined;
36
- obj = obj[k];
37
- }
38
- return obj;
39
- }
40
- export function getWindowHost() {
41
- return getWindowProp('location', 'host');
42
- }
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1 +0,0 @@
1
- export * from './sizeUtils';
@@ -1,44 +0,0 @@
1
- // Function to compare MB
2
- export function exceedsMbLimit(limitMb, payloadMb) {
3
- return payloadMb > limitMb;
4
- }
5
- export function safeJsonSizeInMb(value) {
6
- const seen = new WeakSet();
7
- const json = JSON.stringify(value, (_, v) => {
8
- if (typeof v === "bigint")
9
- return v.toString();
10
- if (typeof v === "object" && v !== null) {
11
- if (seen.has(v))
12
- return "[Circular]";
13
- seen.add(v);
14
- }
15
- return v;
16
- });
17
- return Buffer.byteLength(json, "utf8") / (1024 * 1024);
18
- }
19
- export function dataSizeInMb(data) {
20
- const size = typeof data === "string"
21
- ? Buffer.byteLength(data, "utf8")
22
- : Buffer.byteLength(JSON.stringify(data), "utf8");
23
- return size / (1024 * 1024);
24
- }
25
- export function getJsonSizeInMb(json) {
26
- return Buffer.byteLength(JSON.stringify(json), "utf8") / (1024 * 1024);
27
- }
28
- // Function to calculate data size in KB
29
- export function dataSize(data) {
30
- let size = 0;
31
- if (typeof data === 'string') {
32
- size = Buffer.byteLength(data, 'utf8');
33
- }
34
- else if (Buffer.isBuffer(data)) {
35
- size = data.length;
36
- }
37
- else if (typeof data === 'object') {
38
- size = Buffer.byteLength(JSON.stringify(data), 'utf8');
39
- }
40
- else {
41
- size = Buffer.byteLength(String(data), 'utf8');
42
- }
43
- return size / 1000; // Convert to kilobytes
44
- }
@@ -1 +0,0 @@
1
- export * from './src';
@@ -1,2 +0,0 @@
1
- export * from './string_utils';
2
- export * from './quote_utils';
@@ -1,17 +0,0 @@
1
- /**
2
- * Checks if a value is enclosed in quotes.
3
- */
4
- export function ends_in_quotes(value) {
5
- if (typeof value === 'string') {
6
- if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
7
- return true;
8
- }
9
- }
10
- return false;
11
- }
12
- export function stripQuotes(value) {
13
- if (ends_in_quotes(value)) {
14
- return value.slice(1, -1); // Remove the first and last characters
15
- }
16
- return value; // Return the input unchanged for all other cases
17
- }