@putkoff/abstract-utilities 0.1.209 → 0.1.210
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/esm/index.js
CHANGED
|
@@ -405,9 +405,6 @@ function getResult(obj) {
|
|
|
405
405
|
Object.prototype.hasOwnProperty.call(current, "result")) {
|
|
406
406
|
current = current.result;
|
|
407
407
|
}
|
|
408
|
-
if (current === null || current === void 0 ? void 0 : current.result) {
|
|
409
|
-
current = current.result;
|
|
410
|
-
}
|
|
411
408
|
return current;
|
|
412
409
|
}
|
|
413
410
|
// Determines HTTP method, defaults to GET or POST based on body
|
|
@@ -1061,6 +1058,62 @@ posix.posix = posix;
|
|
|
1061
1058
|
|
|
1062
1059
|
var pathBrowserify = posix;
|
|
1063
1060
|
|
|
1061
|
+
function ensure_list(obj) {
|
|
1062
|
+
const objArray = Array.isArray(obj) ? obj : [obj];
|
|
1063
|
+
return objArray;
|
|
1064
|
+
}
|
|
1065
|
+
function assureString(obj) {
|
|
1066
|
+
return String(obj);
|
|
1067
|
+
}
|
|
1068
|
+
function cleanArray(obj) {
|
|
1069
|
+
obj = assureArray(obj);
|
|
1070
|
+
return Array.from(new Set(obj));
|
|
1071
|
+
}
|
|
1072
|
+
function assureArray(input) {
|
|
1073
|
+
if (typeof input === 'string') {
|
|
1074
|
+
return [input];
|
|
1075
|
+
}
|
|
1076
|
+
if (Array.isArray(input)) {
|
|
1077
|
+
return input.map(item => assureString(item));
|
|
1078
|
+
}
|
|
1079
|
+
return [];
|
|
1080
|
+
}
|
|
1081
|
+
// Constrain T so 'in obj' is allowed
|
|
1082
|
+
function get_key_value(obj, key) {
|
|
1083
|
+
// we cast to any for the indexing, since TS can’t infer arbitrary string keys
|
|
1084
|
+
if (key in obj && obj[key] != null) {
|
|
1085
|
+
return obj[key];
|
|
1086
|
+
}
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
function get(obj, keys, defaultValue = null) {
|
|
1090
|
+
const keyArray = assureArray(keys);
|
|
1091
|
+
if (!obj || keyArray.length === 0) {
|
|
1092
|
+
return defaultValue;
|
|
1093
|
+
}
|
|
1094
|
+
for (const key of keyArray) {
|
|
1095
|
+
const val = get_key_value(obj, key);
|
|
1096
|
+
if (val != null) {
|
|
1097
|
+
return val;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return defaultValue;
|
|
1101
|
+
}
|
|
1102
|
+
function cleanText(input) {
|
|
1103
|
+
// Replace delimiters with spaces and split
|
|
1104
|
+
const str = assureString(input);
|
|
1105
|
+
const words = str.replace(/[_.-]/g, ' '); // Replace _, -, . with space
|
|
1106
|
+
return words;
|
|
1107
|
+
}
|
|
1108
|
+
function getCleanArray(obj) {
|
|
1109
|
+
obj = obj.split(/\s+/) // Split on any whitespace
|
|
1110
|
+
.filter((item) => typeof item === 'string' && item !== '');
|
|
1111
|
+
// Get basename
|
|
1112
|
+
// Remove duplicates using Set
|
|
1113
|
+
const uniqueWords = cleanArray(obj);
|
|
1114
|
+
return uniqueWords;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1064
1117
|
function getSubstring(obj, maxLength = null, minLength = null) {
|
|
1065
1118
|
const objLength = obj.length;
|
|
1066
1119
|
const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
|
|
@@ -1081,6 +1134,30 @@ function truncateString(obj, maxLength = 20) {
|
|
|
1081
1134
|
}
|
|
1082
1135
|
return obj;
|
|
1083
1136
|
}
|
|
1137
|
+
function capitalize_str(string) {
|
|
1138
|
+
string = assureString(string);
|
|
1139
|
+
const string_len = string.length;
|
|
1140
|
+
let init_char = string.toUpperCase();
|
|
1141
|
+
if (string_len > 0) {
|
|
1142
|
+
init_char = string[0].toUpperCase();
|
|
1143
|
+
}
|
|
1144
|
+
let rest_chars = '';
|
|
1145
|
+
if (string_len > 1) {
|
|
1146
|
+
rest_chars = string.slice(1).toLowerCase();
|
|
1147
|
+
}
|
|
1148
|
+
const fin_chars = `${init_char}${rest_chars}`;
|
|
1149
|
+
return fin_chars;
|
|
1150
|
+
}
|
|
1151
|
+
function capitalize(string) {
|
|
1152
|
+
let nu_string = '';
|
|
1153
|
+
string = assureString(string);
|
|
1154
|
+
let objs = string.replace('-', '_').split('_');
|
|
1155
|
+
for (const obj of objs) {
|
|
1156
|
+
let str_obj = capitalize_str(obj);
|
|
1157
|
+
nu_string = `${nu_string} ${str_obj}`;
|
|
1158
|
+
}
|
|
1159
|
+
return eatAll(nu_string, [' ']);
|
|
1160
|
+
}
|
|
1084
1161
|
// string_utils/src/string_utils.ts
|
|
1085
1162
|
function stripPrefixes(str, bases = []) {
|
|
1086
1163
|
/* NEW: coerce whatever arrives into a string */
|
|
@@ -1190,62 +1267,6 @@ function create_list_string(array_obj) {
|
|
|
1190
1267
|
return string;
|
|
1191
1268
|
}
|
|
1192
1269
|
|
|
1193
|
-
function ensure_list(obj) {
|
|
1194
|
-
const objArray = Array.isArray(obj) ? obj : [obj];
|
|
1195
|
-
return objArray;
|
|
1196
|
-
}
|
|
1197
|
-
function assureString(obj) {
|
|
1198
|
-
return String(obj);
|
|
1199
|
-
}
|
|
1200
|
-
function cleanArray(obj) {
|
|
1201
|
-
obj = assureArray(obj);
|
|
1202
|
-
return Array.from(new Set(obj));
|
|
1203
|
-
}
|
|
1204
|
-
function assureArray(input) {
|
|
1205
|
-
if (typeof input === 'string') {
|
|
1206
|
-
return [input];
|
|
1207
|
-
}
|
|
1208
|
-
if (Array.isArray(input)) {
|
|
1209
|
-
return input.map(item => assureString(item));
|
|
1210
|
-
}
|
|
1211
|
-
return [];
|
|
1212
|
-
}
|
|
1213
|
-
// Constrain T so 'in obj' is allowed
|
|
1214
|
-
function get_key_value(obj, key) {
|
|
1215
|
-
// we cast to any for the indexing, since TS can’t infer arbitrary string keys
|
|
1216
|
-
if (key in obj && obj[key] != null) {
|
|
1217
|
-
return obj[key];
|
|
1218
|
-
}
|
|
1219
|
-
return null;
|
|
1220
|
-
}
|
|
1221
|
-
function get(obj, keys, defaultValue = null) {
|
|
1222
|
-
const keyArray = assureArray(keys);
|
|
1223
|
-
if (!obj || keyArray.length === 0) {
|
|
1224
|
-
return defaultValue;
|
|
1225
|
-
}
|
|
1226
|
-
for (const key of keyArray) {
|
|
1227
|
-
const val = get_key_value(obj, key);
|
|
1228
|
-
if (val != null) {
|
|
1229
|
-
return val;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
return defaultValue;
|
|
1233
|
-
}
|
|
1234
|
-
function cleanText(input) {
|
|
1235
|
-
// Replace delimiters with spaces and split
|
|
1236
|
-
const str = assureString(input);
|
|
1237
|
-
const words = str.replace(/[_.-]/g, ' '); // Replace _, -, . with space
|
|
1238
|
-
return words;
|
|
1239
|
-
}
|
|
1240
|
-
function getCleanArray(obj) {
|
|
1241
|
-
obj = obj.split(/\s+/) // Split on any whitespace
|
|
1242
|
-
.filter((item) => typeof item === 'string' && item !== '');
|
|
1243
|
-
// Get basename
|
|
1244
|
-
// Remove duplicates using Set
|
|
1245
|
-
const uniqueWords = cleanArray(obj);
|
|
1246
|
-
return uniqueWords;
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
1270
|
/**
|
|
1250
1271
|
* In the browser we already have a WHATWG URL constructor on window.
|
|
1251
1272
|
* Here we re-export it as “url” so other modules can import it.
|
|
@@ -1573,5 +1594,5 @@ function get_keyword_string(keywords) {
|
|
|
1573
1594
|
return allString;
|
|
1574
1595
|
}
|
|
1575
1596
|
|
|
1576
|
-
export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, assureArray, assureString, callStorage, callWindowMethod, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getBody, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_key_value, get_keyword_string, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, make_path, make_sanitized_path, normalizeUrl, parseResult, processKeywords, readJsonFile, requireToken, safeGlobalProp, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse };
|
|
1597
|
+
export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, assureArray, assureString, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getBody, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_key_value, get_keyword_string, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, make_path, make_sanitized_path, normalizeUrl, parseResult, processKeywords, readJsonFile, requireToken, safeGlobalProp, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse };
|
|
1577
1598
|
//# sourceMappingURL=index.js.map
|