@putkoff/abstract-utilities 1.0.67 → 1.0.68
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/cjs/index.js +64 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +58 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/types/functions/math_utils/index.d.ts +1 -0
- package/dist/types/functions/math_utils/safe_math.d.ts +1 -0
- package/dist/types/functions/math_utils/time_utils.d.ts +1 -0
- package/dist/types/functions/string_utils/src/index.d.ts +1 -0
- package/dist/types/functions/string_utils/src/quote_utils.d.ts +5 -0
- package/dist/types/functions/string_utils/src/string_utils.d.ts +4 -0
- package/dist/types/functions/type_utils/src/json_utils.d.ts +2 -0
- package/dist/types/functions/type_utils/src/null_utils.d.ts +9 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1058,6 +1058,26 @@ function get(obj, keys, defaultValue = null) {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
return defaultValue;
|
|
1060
1060
|
}
|
|
1061
|
+
// Create the accountInfo table if it doesn't already exist
|
|
1062
|
+
function findKeyValue(obj, keyToFind) {
|
|
1063
|
+
if (keyToFind in obj)
|
|
1064
|
+
return obj[keyToFind];
|
|
1065
|
+
for (const key in obj) {
|
|
1066
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
1067
|
+
const result = findKeyValue(obj[key], keyToFind);
|
|
1068
|
+
if (result !== undefined)
|
|
1069
|
+
return result;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return undefined;
|
|
1073
|
+
}
|
|
1074
|
+
function omitKeys(obj, ...keys) {
|
|
1075
|
+
const newObj = Object.assign({}, obj);
|
|
1076
|
+
keys.forEach(key => {
|
|
1077
|
+
delete newObj[key];
|
|
1078
|
+
});
|
|
1079
|
+
return newObj;
|
|
1080
|
+
}
|
|
1061
1081
|
|
|
1062
1082
|
function isType(obj, type) {
|
|
1063
1083
|
if (typeof obj === type) {
|
|
@@ -1443,6 +1463,14 @@ function getSubstring(obj, maxLength = null, minLength = null) {
|
|
|
1443
1463
|
}
|
|
1444
1464
|
return obj.substring(clampedMinLength, clampedMaxLength);
|
|
1445
1465
|
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Sanitize a string by removing null bytes and trimming whitespace.
|
|
1468
|
+
*/
|
|
1469
|
+
function sanitizeString(input) {
|
|
1470
|
+
if (!input)
|
|
1471
|
+
return input;
|
|
1472
|
+
return input.replace(/\u0000/g, "").trim(); // Remove null bytes and whitespace
|
|
1473
|
+
}
|
|
1446
1474
|
function truncateString(obj, maxLength = 20) {
|
|
1447
1475
|
const objLength = obj.length;
|
|
1448
1476
|
if (objLength > maxLength && maxLength) {
|
|
@@ -1601,6 +1629,24 @@ function eatouter(str, listObjects) {
|
|
|
1601
1629
|
return eatOuter(str, listObjects);
|
|
1602
1630
|
}
|
|
1603
1631
|
|
|
1632
|
+
/**
|
|
1633
|
+
* Checks if a value is enclosed in quotes.
|
|
1634
|
+
*/
|
|
1635
|
+
function ends_in_quotes(value) {
|
|
1636
|
+
if (typeof value === 'string') {
|
|
1637
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
1638
|
+
return true;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
return false;
|
|
1642
|
+
}
|
|
1643
|
+
function stripQuotes(value) {
|
|
1644
|
+
if (ends_in_quotes(value)) {
|
|
1645
|
+
return value.slice(1, -1); // Remove the first and last characters
|
|
1646
|
+
}
|
|
1647
|
+
return value; // Return the input unchanged for all other cases
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1604
1650
|
/**
|
|
1605
1651
|
* In the browser we already have a WHATWG URL constructor on window.
|
|
1606
1652
|
* Here we re-export it as “url” so other modules can import it.
|
|
@@ -1910,6 +1956,12 @@ function roundPercentage(x) {
|
|
|
1910
1956
|
function exponential(i, k) {
|
|
1911
1957
|
return i * (10 ** (k));
|
|
1912
1958
|
}
|
|
1959
|
+
function isZero(obj) {
|
|
1960
|
+
if (obj == 0) {
|
|
1961
|
+
return true;
|
|
1962
|
+
}
|
|
1963
|
+
return false;
|
|
1964
|
+
}
|
|
1913
1965
|
|
|
1914
1966
|
const SECOND = 1;
|
|
1915
1967
|
const ZEPTOSECOND = exponential(SECOND, -21);
|
|
@@ -2076,6 +2128,11 @@ const fromMps = (v, dist_unit, time_unit) => mpsToSpeed(v, dist_unit, time_unit)
|
|
|
2076
2128
|
const isFiniteNum = (x) => Number.isFinite(x);
|
|
2077
2129
|
const fmt = (n, digits = 2) => isFiniteNum(n) ? n.toFixed(digits) : "N/A";
|
|
2078
2130
|
|
|
2131
|
+
// Function to check time interval
|
|
2132
|
+
function isTimeInterval(timeObj, interval) {
|
|
2133
|
+
return (Date.now() / 1000 - timeObj) < (interval - 1);
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2079
2136
|
function getSafeDocument() {
|
|
2080
2137
|
return typeof document !== 'undefined' ? document : undefined;
|
|
2081
2138
|
}
|
|
@@ -2399,5 +2456,5 @@ function get_keyword_string(keywords) {
|
|
|
2399
2456
|
return allString;
|
|
2400
2457
|
}
|
|
2401
2458
|
|
|
2402
|
-
export { API_PREFIX, ATTOSECOND, BASE_URL, CENTISECOND, DAY, DAY_IN_S, DECISECOND, DEV_PREFIX, DIST_ALIASES, DIST_FACTORS, DOMAIN_NAME, DistanceConverter, FEET_PER_METER, FEMTOSECOND, HOUR, HOUR_IN_S, KMS_PER_METER, MEDIA_TYPES, METERS_PER_FOOT, METERS_PER_KM, METERS_PER_MILE, MICROSECOND, MILES_PER_METER, MILISECOND, MIME_TYPES, MINUTE, MIN_IN_S, MONTH, MONTH_IN_S, MPerS_TO_MiPerH, MiPerH_TO_MPerS, NANOSECOND, PI, PI2, PICOSECOND, PROD_PREFIX, PROTOCOL, SECOND, SECONDS_PER_DAY, SECONDS_PER_HOUR, SECONDS_PER_MINUTE, SUB_DIR, SpeedConverter, TIME_ALIASES, TIME_FACTORS, TimeConverter, YEAR, YEAR_IN_S, ZEPTOSECOND, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, assurearray, assurelist, assurenumber, assurestring, callStorage, callWindowMethod, canonDist, canonTime, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, confirmType, confirm_type, convertDistance, convertSpeed, convertTime, create_list_string, decodeJwt, distanceToMeters, eatAll, eatElse, eatInner, eatOuter, eatall, eatinner, eatouter, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, ensurearray, ensurelist, ensurenumber, ensurestring, exponential, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, fmt, formatNumber, fromMeters, fromMps, fromSeconds, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getBaseDir, getBasename, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDirname, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getExtname, getFetchVars, getFilename, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSplitext, getSrcDir, getSubstring, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, getbasename, getdirname, getextname, getfilename, getsplitext, isFiniteNum, isMediaType, isNum, isStrInString, isTokenExpired, isType, is_media_type, loadConfig, makePath, make_path, make_sanitized_path, makepath, metersToDistance, mpsToSpeed, normalizeUrl, parseResult, pathJoin, path_join, path_to_url, pathjoin, processKeywords, readJsonFile, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, secondsToTime, speedToMps, stripPrefixes, timeToSeconds, toMeters, toSeconds, truncateString, tryEatPrefix, tryParse, urlJoin, url_to_path, urljoin, velocityFromMs, velocityToMs };
|
|
2459
|
+
export { API_PREFIX, ATTOSECOND, BASE_URL, CENTISECOND, DAY, DAY_IN_S, DECISECOND, DEV_PREFIX, DIST_ALIASES, DIST_FACTORS, DOMAIN_NAME, DistanceConverter, FEET_PER_METER, FEMTOSECOND, HOUR, HOUR_IN_S, KMS_PER_METER, MEDIA_TYPES, METERS_PER_FOOT, METERS_PER_KM, METERS_PER_MILE, MICROSECOND, MILES_PER_METER, MILISECOND, MIME_TYPES, MINUTE, MIN_IN_S, MONTH, MONTH_IN_S, MPerS_TO_MiPerH, MiPerH_TO_MPerS, NANOSECOND, PI, PI2, PICOSECOND, PROD_PREFIX, PROTOCOL, SECOND, SECONDS_PER_DAY, SECONDS_PER_HOUR, SECONDS_PER_MINUTE, SUB_DIR, SpeedConverter, TIME_ALIASES, TIME_FACTORS, TimeConverter, YEAR, YEAR_IN_S, ZEPTOSECOND, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, assurearray, assurelist, assurenumber, assurestring, callStorage, callWindowMethod, canonDist, canonTime, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, confirmType, confirm_type, convertDistance, convertSpeed, convertTime, create_list_string, decodeJwt, distanceToMeters, eatAll, eatElse, eatInner, eatOuter, eatall, eatinner, eatouter, ends_in_quotes, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, ensurearray, ensurelist, ensurenumber, ensurestring, exponential, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, findKeyValue, fmt, formatNumber, fromMeters, fromMps, fromSeconds, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getBaseDir, getBasename, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDirname, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getExtname, getFetchVars, getFilename, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSplitext, getSrcDir, getSubstring, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, getbasename, getdirname, getextname, getfilename, getsplitext, isFiniteNum, isMediaType, isNum, isStrInString, isTimeInterval, isTokenExpired, isType, isZero, is_media_type, loadConfig, makePath, make_path, make_sanitized_path, makepath, metersToDistance, mpsToSpeed, normalizeUrl, omitKeys, parseResult, pathJoin, path_join, path_to_url, pathjoin, processKeywords, readJsonFile, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, sanitizeString, secondsToTime, speedToMps, stripPrefixes, stripQuotes, timeToSeconds, toMeters, toSeconds, truncateString, tryEatPrefix, tryParse, urlJoin, url_to_path, urljoin, velocityFromMs, velocityToMs };
|
|
2403
2460
|
//# sourceMappingURL=index.js.map
|