@salespark/toolkit 2.1.12 → 2.1.14
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 +6 -3
- package/dist/index.cjs +91 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -3
- package/dist/index.d.ts +66 -3
- package/dist/index.js +88 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -624,14 +624,16 @@ declare const isNullOrUndefinedOrNaN: (value: unknown) => boolean;
|
|
|
624
624
|
* @param {Number} bytes - Number of bytes to format
|
|
625
625
|
* @param {Boolean} si - True for metric (SI, base 1000), false for binary (IEC, base 1024)
|
|
626
626
|
* @param {Number} dp - Decimal places
|
|
627
|
+
* @param {Boolean} noSpace - If true, omits space between number and unit
|
|
627
628
|
* History:
|
|
628
629
|
* 21-08-2025: Created
|
|
630
|
+
* 15-01-2026: Returns "Bytes" instead of "B" for values < threshold for clarity and added noSpace option
|
|
629
631
|
****************************************************/
|
|
630
|
-
declare const formatBytes: (bytes: number, si?: boolean, dp?: number) => string;
|
|
632
|
+
declare const formatBytes: (bytes: number, si?: boolean, dp?: number, noSpace?: boolean) => string;
|
|
631
633
|
/**
|
|
632
634
|
* @deprecated Use `formatBytes` instead.
|
|
633
635
|
*/
|
|
634
|
-
declare const humanFileSize: (bytes: number, si?: boolean, dp?: number) => string;
|
|
636
|
+
declare const humanFileSize: (bytes: number, si?: boolean, dp?: number, noSpace?: boolean) => string;
|
|
635
637
|
/******************************************************
|
|
636
638
|
* ##: String Similarity
|
|
637
639
|
* Returns the similarity between two strings (0..1)
|
|
@@ -828,8 +830,69 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
|
828
830
|
recommendations: string[];
|
|
829
831
|
};
|
|
830
832
|
|
|
833
|
+
type DeferFn = () => void | Promise<void>;
|
|
834
|
+
/******************************************************************
|
|
835
|
+
* ##: Defer work to run right after return using a microtask
|
|
836
|
+
* Schedules work after the current call stack, using queueMicrotask or
|
|
837
|
+
* Promise.then, and swallows sync/async errors to avoid impacting callers.
|
|
838
|
+
*
|
|
839
|
+
* TL;DR: Runs post-return work ASAP without blocking the caller.
|
|
840
|
+
* Best for small but important tasks that must run soon.
|
|
841
|
+
* @param {DeferFn} fn - Function to execute after the current stack completes
|
|
842
|
+
* @returns {void} - Does not return a value
|
|
843
|
+
* History:
|
|
844
|
+
* 09-01-2026: Created
|
|
845
|
+
******************************************************************/
|
|
846
|
+
declare const deferPostReturn: (fn: DeferFn) => void;
|
|
847
|
+
/******************************************************************
|
|
848
|
+
* ##: Defer non-critical work with low priority scheduling
|
|
849
|
+
* Schedules work after more urgent tasks, using setImmediate when available
|
|
850
|
+
* (or setTimeout), and swallows sync/async errors to keep execution safe.
|
|
851
|
+
*
|
|
852
|
+
* TL;DR: Runs low-priority work as late as possible.
|
|
853
|
+
* Ideal for logs, metrics, and cleanup that must not compete with requests.
|
|
854
|
+
* @param {DeferFn} fn - Function to execute with low priority scheduling
|
|
855
|
+
* @returns {void} - Does not return a value
|
|
856
|
+
* History:
|
|
857
|
+
* 09-01-2026: Created
|
|
858
|
+
******************************************************************/
|
|
859
|
+
declare const deferNonCritical: (fn: DeferFn) => void;
|
|
860
|
+
type HttpResponseLike = {
|
|
861
|
+
once: (event: "finish" | "close", listener: (...args: any[]) => void) => void;
|
|
862
|
+
writableEnded?: boolean;
|
|
863
|
+
};
|
|
864
|
+
/******************************************************************
|
|
865
|
+
* ##: Defer work until after the HTTP response finishes
|
|
866
|
+
* Runs work only after the response is completed (finish/close), ensures it
|
|
867
|
+
* executes once, and schedules via microtask to avoid impacting response time.
|
|
868
|
+
*
|
|
869
|
+
* TL;DR: Runs work after sending the response, exactly once.
|
|
870
|
+
* Use for post-response tasks like logging, metrics, or async side effects.
|
|
871
|
+
* @param {HttpResponseLike} res - Response-like object that emits finish/close events
|
|
872
|
+
* @param {DeferFn} fn - Function to execute after the response has completed
|
|
873
|
+
* @returns {void} - Does not return a value
|
|
874
|
+
* History:
|
|
875
|
+
* 09-01-2026: Created
|
|
876
|
+
******************************************************************/
|
|
877
|
+
declare const deferAfterResponse: (res: HttpResponseLike, fn: DeferFn) => void;
|
|
878
|
+
/******************************************************************
|
|
879
|
+
* ##: Defer low-priority work until after the HTTP response finishes
|
|
880
|
+
* Runs work only after the response is completed (finish/close), ensures it
|
|
881
|
+
* executes once, and schedules with low priority to avoid competing with traffic.
|
|
882
|
+
*
|
|
883
|
+
* TL;DR: Runs low-priority work after sending the response, exactly once.
|
|
884
|
+
* Best for non-urgent metrics, logs, and cleanup after request completion.
|
|
885
|
+
* @param {HttpResponseLike} res - Response-like object that emits finish/close events
|
|
886
|
+
* @param {DeferFn} fn - Function to execute after the response has completed
|
|
887
|
+
* @returns {void} - Does not return a value
|
|
888
|
+
* History:
|
|
889
|
+
* 09-01-2025: Created
|
|
890
|
+
* 09-01-2025: Fixed duplicate execution bug (finish + close both firing)
|
|
891
|
+
******************************************************************/
|
|
892
|
+
declare const deferAfterResponseNonCritical: (res: HttpResponseLike, fn: DeferFn) => void;
|
|
893
|
+
|
|
831
894
|
/** Environment helpers (runtime-agnostic checks) */
|
|
832
895
|
declare const isBrowser: boolean;
|
|
833
896
|
declare const isNode: boolean;
|
|
834
897
|
|
|
835
|
-
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
898
|
+
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.d.ts
CHANGED
|
@@ -624,14 +624,16 @@ declare const isNullOrUndefinedOrNaN: (value: unknown) => boolean;
|
|
|
624
624
|
* @param {Number} bytes - Number of bytes to format
|
|
625
625
|
* @param {Boolean} si - True for metric (SI, base 1000), false for binary (IEC, base 1024)
|
|
626
626
|
* @param {Number} dp - Decimal places
|
|
627
|
+
* @param {Boolean} noSpace - If true, omits space between number and unit
|
|
627
628
|
* History:
|
|
628
629
|
* 21-08-2025: Created
|
|
630
|
+
* 15-01-2026: Returns "Bytes" instead of "B" for values < threshold for clarity and added noSpace option
|
|
629
631
|
****************************************************/
|
|
630
|
-
declare const formatBytes: (bytes: number, si?: boolean, dp?: number) => string;
|
|
632
|
+
declare const formatBytes: (bytes: number, si?: boolean, dp?: number, noSpace?: boolean) => string;
|
|
631
633
|
/**
|
|
632
634
|
* @deprecated Use `formatBytes` instead.
|
|
633
635
|
*/
|
|
634
|
-
declare const humanFileSize: (bytes: number, si?: boolean, dp?: number) => string;
|
|
636
|
+
declare const humanFileSize: (bytes: number, si?: boolean, dp?: number, noSpace?: boolean) => string;
|
|
635
637
|
/******************************************************
|
|
636
638
|
* ##: String Similarity
|
|
637
639
|
* Returns the similarity between two strings (0..1)
|
|
@@ -828,8 +830,69 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
|
828
830
|
recommendations: string[];
|
|
829
831
|
};
|
|
830
832
|
|
|
833
|
+
type DeferFn = () => void | Promise<void>;
|
|
834
|
+
/******************************************************************
|
|
835
|
+
* ##: Defer work to run right after return using a microtask
|
|
836
|
+
* Schedules work after the current call stack, using queueMicrotask or
|
|
837
|
+
* Promise.then, and swallows sync/async errors to avoid impacting callers.
|
|
838
|
+
*
|
|
839
|
+
* TL;DR: Runs post-return work ASAP without blocking the caller.
|
|
840
|
+
* Best for small but important tasks that must run soon.
|
|
841
|
+
* @param {DeferFn} fn - Function to execute after the current stack completes
|
|
842
|
+
* @returns {void} - Does not return a value
|
|
843
|
+
* History:
|
|
844
|
+
* 09-01-2026: Created
|
|
845
|
+
******************************************************************/
|
|
846
|
+
declare const deferPostReturn: (fn: DeferFn) => void;
|
|
847
|
+
/******************************************************************
|
|
848
|
+
* ##: Defer non-critical work with low priority scheduling
|
|
849
|
+
* Schedules work after more urgent tasks, using setImmediate when available
|
|
850
|
+
* (or setTimeout), and swallows sync/async errors to keep execution safe.
|
|
851
|
+
*
|
|
852
|
+
* TL;DR: Runs low-priority work as late as possible.
|
|
853
|
+
* Ideal for logs, metrics, and cleanup that must not compete with requests.
|
|
854
|
+
* @param {DeferFn} fn - Function to execute with low priority scheduling
|
|
855
|
+
* @returns {void} - Does not return a value
|
|
856
|
+
* History:
|
|
857
|
+
* 09-01-2026: Created
|
|
858
|
+
******************************************************************/
|
|
859
|
+
declare const deferNonCritical: (fn: DeferFn) => void;
|
|
860
|
+
type HttpResponseLike = {
|
|
861
|
+
once: (event: "finish" | "close", listener: (...args: any[]) => void) => void;
|
|
862
|
+
writableEnded?: boolean;
|
|
863
|
+
};
|
|
864
|
+
/******************************************************************
|
|
865
|
+
* ##: Defer work until after the HTTP response finishes
|
|
866
|
+
* Runs work only after the response is completed (finish/close), ensures it
|
|
867
|
+
* executes once, and schedules via microtask to avoid impacting response time.
|
|
868
|
+
*
|
|
869
|
+
* TL;DR: Runs work after sending the response, exactly once.
|
|
870
|
+
* Use for post-response tasks like logging, metrics, or async side effects.
|
|
871
|
+
* @param {HttpResponseLike} res - Response-like object that emits finish/close events
|
|
872
|
+
* @param {DeferFn} fn - Function to execute after the response has completed
|
|
873
|
+
* @returns {void} - Does not return a value
|
|
874
|
+
* History:
|
|
875
|
+
* 09-01-2026: Created
|
|
876
|
+
******************************************************************/
|
|
877
|
+
declare const deferAfterResponse: (res: HttpResponseLike, fn: DeferFn) => void;
|
|
878
|
+
/******************************************************************
|
|
879
|
+
* ##: Defer low-priority work until after the HTTP response finishes
|
|
880
|
+
* Runs work only after the response is completed (finish/close), ensures it
|
|
881
|
+
* executes once, and schedules with low priority to avoid competing with traffic.
|
|
882
|
+
*
|
|
883
|
+
* TL;DR: Runs low-priority work after sending the response, exactly once.
|
|
884
|
+
* Best for non-urgent metrics, logs, and cleanup after request completion.
|
|
885
|
+
* @param {HttpResponseLike} res - Response-like object that emits finish/close events
|
|
886
|
+
* @param {DeferFn} fn - Function to execute after the response has completed
|
|
887
|
+
* @returns {void} - Does not return a value
|
|
888
|
+
* History:
|
|
889
|
+
* 09-01-2025: Created
|
|
890
|
+
* 09-01-2025: Fixed duplicate execution bug (finish + close both firing)
|
|
891
|
+
******************************************************************/
|
|
892
|
+
declare const deferAfterResponseNonCritical: (res: HttpResponseLike, fn: DeferFn) => void;
|
|
893
|
+
|
|
831
894
|
/** Environment helpers (runtime-agnostic checks) */
|
|
832
895
|
declare const isBrowser: boolean;
|
|
833
896
|
declare const isNode: boolean;
|
|
834
897
|
|
|
835
|
-
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
898
|
+
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.js
CHANGED
|
@@ -551,11 +551,11 @@ var isNullOrUndefinedInArray = hasNilOrEmpty;
|
|
|
551
551
|
var isNullOrUndefinedEmptyOrZero = isNilEmptyOrZeroLen;
|
|
552
552
|
var isNullUndefinedOrZero = isNilOrZeroLen;
|
|
553
553
|
var isNullOrUndefinedOrNaN = isNilOrNaN;
|
|
554
|
-
var formatBytes = (bytes, si = false, dp = 1) => {
|
|
554
|
+
var formatBytes = (bytes, si = false, dp = 1, noSpace = false) => {
|
|
555
555
|
if (!Number.isFinite(bytes)) return "NaN";
|
|
556
556
|
const thresh = si ? 1e3 : 1024;
|
|
557
557
|
const abs = Math.abs(bytes);
|
|
558
|
-
if (abs < thresh) return `${bytes}
|
|
558
|
+
if (abs < thresh) return `${bytes} Bytes`;
|
|
559
559
|
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
560
560
|
let u = -1;
|
|
561
561
|
const r = 10 ** dp;
|
|
@@ -564,7 +564,7 @@ var formatBytes = (bytes, si = false, dp = 1) => {
|
|
|
564
564
|
value /= thresh;
|
|
565
565
|
++u;
|
|
566
566
|
} while (Math.round(Math.abs(value) * r) / r >= thresh && u < units.length - 1);
|
|
567
|
-
return `${value.toFixed(dp)} ${units[u]}`;
|
|
567
|
+
return `${value.toFixed(dp)}${noSpace ? "" : " "}${units[u]}`;
|
|
568
568
|
};
|
|
569
569
|
var humanFileSize = formatBytes;
|
|
570
570
|
var levenshtein = (a, b) => {
|
|
@@ -1743,10 +1743,94 @@ var assessSecurityRisks = (risks) => {
|
|
|
1743
1743
|
return { score, level, recommendations };
|
|
1744
1744
|
};
|
|
1745
1745
|
|
|
1746
|
+
// src/utils/defer.ts
|
|
1747
|
+
var swallow = (p) => p.catch(() => {
|
|
1748
|
+
});
|
|
1749
|
+
var deferPostReturn = (fn) => {
|
|
1750
|
+
if (typeof fn !== "function") return;
|
|
1751
|
+
const run = () => {
|
|
1752
|
+
try {
|
|
1753
|
+
const result = fn();
|
|
1754
|
+
swallow(Promise.resolve(result));
|
|
1755
|
+
} catch {
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
if (typeof queueMicrotask === "function") {
|
|
1759
|
+
queueMicrotask(run);
|
|
1760
|
+
} else {
|
|
1761
|
+
Promise.resolve().then(run);
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
var deferNonCritical = (fn) => {
|
|
1765
|
+
if (typeof fn !== "function") return;
|
|
1766
|
+
const run = () => {
|
|
1767
|
+
try {
|
|
1768
|
+
const result = fn();
|
|
1769
|
+
swallow(Promise.resolve(result));
|
|
1770
|
+
} catch {
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
if (typeof setImmediate === "function") {
|
|
1774
|
+
setImmediate(run);
|
|
1775
|
+
} else {
|
|
1776
|
+
setTimeout(run, 0);
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
var deferAfterResponse = (res, fn) => {
|
|
1780
|
+
if (typeof fn !== "function") return;
|
|
1781
|
+
if (res?.writableEnded === true) {
|
|
1782
|
+
deferPostReturn(fn);
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
if (!res || typeof res.once !== "function") {
|
|
1786
|
+
deferPostReturn(fn);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
let executed = false;
|
|
1790
|
+
const executeOnce = () => {
|
|
1791
|
+
if (executed) return;
|
|
1792
|
+
executed = true;
|
|
1793
|
+
deferPostReturn(fn);
|
|
1794
|
+
};
|
|
1795
|
+
try {
|
|
1796
|
+
res.once("finish", executeOnce);
|
|
1797
|
+
res.once("close", executeOnce);
|
|
1798
|
+
} catch {
|
|
1799
|
+
if (!executed) {
|
|
1800
|
+
deferPostReturn(fn);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1804
|
+
var deferAfterResponseNonCritical = (res, fn) => {
|
|
1805
|
+
if (typeof fn !== "function") return;
|
|
1806
|
+
if (res?.writableEnded === true) {
|
|
1807
|
+
deferNonCritical(fn);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if (!res || typeof res.once !== "function") {
|
|
1811
|
+
deferNonCritical(fn);
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
let executed = false;
|
|
1815
|
+
const executeOnce = () => {
|
|
1816
|
+
if (executed) return;
|
|
1817
|
+
executed = true;
|
|
1818
|
+
deferNonCritical(fn);
|
|
1819
|
+
};
|
|
1820
|
+
try {
|
|
1821
|
+
res.once("finish", executeOnce);
|
|
1822
|
+
res.once("close", executeOnce);
|
|
1823
|
+
} catch {
|
|
1824
|
+
if (!executed) {
|
|
1825
|
+
deferNonCritical(fn);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1746
1830
|
// src/index.ts
|
|
1747
1831
|
var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
|
|
1748
1832
|
var isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
1749
1833
|
|
|
1750
|
-
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
1834
|
+
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
1751
1835
|
//# sourceMappingURL=index.js.map
|
|
1752
1836
|
//# sourceMappingURL=index.js.map
|