@salespark/toolkit 2.1.6 → 2.1.8

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/index.d.cts CHANGED
@@ -231,7 +231,7 @@ declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): O
231
231
  * 21-08-2025: Created
232
232
  ****************************************************/
233
233
  declare function objectToString(obj: unknown): string;
234
- declare function cleanObject<T = unknown>(obj: T): any;
234
+ declare function cleanObject<T = unknown>(obj: T, removeEmptyString?: boolean): any;
235
235
 
236
236
  /******************************************************
237
237
  * ##: Slugify String
@@ -285,9 +285,9 @@ declare const basicSanitize: typeof sanitize;
285
285
  /******************************************************
286
286
  * ##: Clamp Number
287
287
  * Restricts a number to be within the min and max bounds
288
- * @param {Number} n - Number to clamp
289
- * @param {Number} min - Minimum value
290
- * @param {Number} max - Maximum value
288
+ * @param {number} n - Number to clamp
289
+ * @param {number} min - Minimum value
290
+ * @param {number} max - Maximum value
291
291
  * History:
292
292
  * 21-08-2025: Created
293
293
  ****************************************************/
@@ -295,8 +295,8 @@ declare const clamp: (n: number, min: number, max: number) => number;
295
295
  /******************************************************
296
296
  * ##: Fixed Decimal Rounding
297
297
  * Rounds a number to a fixed number of decimals without floating point surprises
298
- * @param {Number} n - Number to round
299
- * @param {Number} decimals - Number of decimal places
298
+ * @param {number} n - Number to round
299
+ * @param {number} decimals - Number of decimal places
300
300
  * History:
301
301
  * 21-08-2025: Created
302
302
  ****************************************************/
@@ -308,12 +308,82 @@ declare function round(n: number, decimals?: number): number;
308
308
  * Notes:
309
309
  * Examples: safeParseInt("42") -> 42, safeParseInt("abc", 10) -> 10, safeParseInt(undefined) -> 0, safeParseInt(3.9) -> 3
310
310
  * @param {unknown} value - Value to convert
311
- * @param {Number} defaultValue - Default value if parsing fails
311
+ * @param {number} defaultValue - Default value if parsing fails
312
312
  * History:
313
313
  * 21-08-2025: Created
314
314
  * 29-10-2025: Renamed from toInteger to safeParseInt
315
315
  ****************************************************/
316
316
  declare function safeParseInt(value: unknown, defaultValue?: number): number;
317
+ /******************************************************
318
+ * ##: Safe Addition
319
+ * Adds two numbers with precision normalization and operand validation.
320
+ *
321
+ * Notes:
322
+ * Returns 0 when operands are invalid or if toFixed throws.
323
+ * Examples: safeAdd(0.1, 0.2, 2) -> 0.3, safeAdd(NaN, 5) -> 0
324
+ * @param {number} a - Augend
325
+ * @param {number} b - Addend
326
+ * @param {number} decimals - Decimal places for rounding (default 2)
327
+ * History:
328
+ * 01-12-2025: Created
329
+ ****************************************************/
330
+ declare function safeAdd(a: number, b: number, decimals?: number): number;
331
+ /******************************************************
332
+ * ##: Safe Multiplication
333
+ * Multiplies two numbers with precision normalization and operand validation.
334
+ *
335
+ * Notes:
336
+ * Returns 0 when operands are invalid or on computation errors.
337
+ * Examples: safeMultiply(0.1, 0.2, 4) -> 0.02, safeMultiply(Infinity, 2) -> 0
338
+ * @param {number} a - First factor
339
+ * @param {number} b - Second factor
340
+ * @param {number} decimals - Decimal places for rounding (default 2)
341
+ * History:
342
+ * 01-12-2025: Created
343
+ ****************************************************/
344
+ declare function safeMultiply(a: number, b: number, decimals?: number): number;
345
+ /******************************************************
346
+ * ##: Safe Subtraction
347
+ * Subtracts two numbers with precision normalization and operand validation.
348
+ *
349
+ * Notes:
350
+ * Returns 0 when operands are invalid or on computation errors.
351
+ * Examples: safeSubtract(10, 3.3333, 2) -> 6.67, safeSubtract(5, NaN) -> 0
352
+ * @param {number} a - Minuend
353
+ * @param {number} b - Subtrahend
354
+ * @param {number} decimals - Decimal places for rounding (default 2)
355
+ * History:
356
+ * 01-12-2025: Created
357
+ ****************************************************/
358
+ declare function safeSubtract(a: number, b: number, decimals?: number): number;
359
+ /******************************************************
360
+ * ##: Safe Division
361
+ * Divides two numbers with precision normalization, operand validation, and zero checks.
362
+ *
363
+ * Notes:
364
+ * Returns 0 when operands are invalid or divisor is zero.
365
+ * Examples: safeDivide(1, 3, 3) -> 0.333, safeDivide(10, 0) -> 0
366
+ * @param {number} a - Dividend
367
+ * @param {number} b - Divisor
368
+ * @param {number} decimals - Decimal places for rounding (default 2)
369
+ * History:
370
+ * 01-12-2025: Created
371
+ ****************************************************/
372
+ declare function safeDivide(a: number, b: number, decimals?: number): number;
373
+ /******************************************************
374
+ * ##: Safe Number Comparison
375
+ * Compares two numbers using fixed decimal precision with operand validation.
376
+ *
377
+ * Notes:
378
+ * Returns false when operands are invalid.
379
+ * Examples: numbersEqual(0.1 + 0.2, 0.3) -> true, numbersEqual(NaN, 1) -> false
380
+ * @param {number} a - First number
381
+ * @param {number} b - Second number
382
+ * @param {number} decimals - Decimal places for comparison (default 2)
383
+ * History:
384
+ * 01-12-2025: Created
385
+ ****************************************************/
386
+ declare function numbersEqual(a: number, b: number, decimals?: number): boolean;
317
387
  /**
318
388
  * @deprecated Use `safeParseFloat` instead.
319
389
  */
@@ -324,8 +394,9 @@ declare const toInteger: typeof safeParseInt;
324
394
  *
325
395
  * Notes:
326
396
  * Handles commas as decimal/thousands separators. Returns 0 for null/undefined/empty string or invalid parsing.
327
- * Examples: safeParseFloat("123.45") -> 123.45, safeParseFloat("123,45") -> 123.45, safeParseFloat("1,234.56") -> 1234.56, safeParseFloat("abc", 2) -> 0, safeParseFloat(42) -> 42 * @param {unknown} value - Value to convert
328
- * @param {Number} decimals - Number of decimal places
397
+ * Examples: safeParseFloat("123.45") -> 123.45, safeParseFloat("123,45") -> 123.45, safeParseFloat("1,234.56") -> 1234.56, safeParseFloat("abc", 2) -> 0, safeParseFloat(42) -> 42
398
+ * @param {unknown} value - Value to convert
399
+ * @param {number} decimals - Number of decimal places
329
400
  * History:
330
401
  * 21-08-2025: Created
331
402
  * 29-10-2025: Renamed from toNumber to safeParseFloat
@@ -346,8 +417,8 @@ declare const parseToNumber: typeof safeParseFloat;
346
417
  *
347
418
  * Notes:
348
419
  * Options: length (default 6), charset (default "0123456789"), noLeadingZero (if true, first char not "0"). Returns a string to preserve leading zeros. Uses Web Crypto when possible; otherwise falls back to Math.random().
349
- * @param {Number} length - Number of digits
350
- * @param {Object} options - Options: charset, noLeadingZero
420
+ * @param {number} length - Number of digits
421
+ * @param {object} options - Options: charset, noLeadingZero
351
422
  * History:
352
423
  * 21-08-2025: Created
353
424
  ****************************************************/
@@ -366,7 +437,7 @@ declare const otp: typeof randomDigits;
366
437
  * Intelligently handles European number formats (1.234,56) and US formats (1,234.56).
367
438
  * Converts strings to numbers and applies decimal formatting.
368
439
  * @param {number|string|null|undefined} value Number value to format
369
- * @param {number} decimals Number of decimal places (default: 2)
440
+ * @param {number} decimals - Number of decimal places (default: 2)
370
441
  * @returns {string} Formatted number string with specified decimals
371
442
  * History:
372
443
  * 16-10-2025: Created
@@ -710,4 +781,4 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
710
781
  declare const isBrowser: boolean;
711
782
  declare const isNode: boolean;
712
783
 
713
- export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseFloat, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
784
+ export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.d.ts CHANGED
@@ -231,7 +231,7 @@ declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): O
231
231
  * 21-08-2025: Created
232
232
  ****************************************************/
233
233
  declare function objectToString(obj: unknown): string;
234
- declare function cleanObject<T = unknown>(obj: T): any;
234
+ declare function cleanObject<T = unknown>(obj: T, removeEmptyString?: boolean): any;
235
235
 
236
236
  /******************************************************
237
237
  * ##: Slugify String
@@ -285,9 +285,9 @@ declare const basicSanitize: typeof sanitize;
285
285
  /******************************************************
286
286
  * ##: Clamp Number
287
287
  * Restricts a number to be within the min and max bounds
288
- * @param {Number} n - Number to clamp
289
- * @param {Number} min - Minimum value
290
- * @param {Number} max - Maximum value
288
+ * @param {number} n - Number to clamp
289
+ * @param {number} min - Minimum value
290
+ * @param {number} max - Maximum value
291
291
  * History:
292
292
  * 21-08-2025: Created
293
293
  ****************************************************/
@@ -295,8 +295,8 @@ declare const clamp: (n: number, min: number, max: number) => number;
295
295
  /******************************************************
296
296
  * ##: Fixed Decimal Rounding
297
297
  * Rounds a number to a fixed number of decimals without floating point surprises
298
- * @param {Number} n - Number to round
299
- * @param {Number} decimals - Number of decimal places
298
+ * @param {number} n - Number to round
299
+ * @param {number} decimals - Number of decimal places
300
300
  * History:
301
301
  * 21-08-2025: Created
302
302
  ****************************************************/
@@ -308,12 +308,82 @@ declare function round(n: number, decimals?: number): number;
308
308
  * Notes:
309
309
  * Examples: safeParseInt("42") -> 42, safeParseInt("abc", 10) -> 10, safeParseInt(undefined) -> 0, safeParseInt(3.9) -> 3
310
310
  * @param {unknown} value - Value to convert
311
- * @param {Number} defaultValue - Default value if parsing fails
311
+ * @param {number} defaultValue - Default value if parsing fails
312
312
  * History:
313
313
  * 21-08-2025: Created
314
314
  * 29-10-2025: Renamed from toInteger to safeParseInt
315
315
  ****************************************************/
316
316
  declare function safeParseInt(value: unknown, defaultValue?: number): number;
317
+ /******************************************************
318
+ * ##: Safe Addition
319
+ * Adds two numbers with precision normalization and operand validation.
320
+ *
321
+ * Notes:
322
+ * Returns 0 when operands are invalid or if toFixed throws.
323
+ * Examples: safeAdd(0.1, 0.2, 2) -> 0.3, safeAdd(NaN, 5) -> 0
324
+ * @param {number} a - Augend
325
+ * @param {number} b - Addend
326
+ * @param {number} decimals - Decimal places for rounding (default 2)
327
+ * History:
328
+ * 01-12-2025: Created
329
+ ****************************************************/
330
+ declare function safeAdd(a: number, b: number, decimals?: number): number;
331
+ /******************************************************
332
+ * ##: Safe Multiplication
333
+ * Multiplies two numbers with precision normalization and operand validation.
334
+ *
335
+ * Notes:
336
+ * Returns 0 when operands are invalid or on computation errors.
337
+ * Examples: safeMultiply(0.1, 0.2, 4) -> 0.02, safeMultiply(Infinity, 2) -> 0
338
+ * @param {number} a - First factor
339
+ * @param {number} b - Second factor
340
+ * @param {number} decimals - Decimal places for rounding (default 2)
341
+ * History:
342
+ * 01-12-2025: Created
343
+ ****************************************************/
344
+ declare function safeMultiply(a: number, b: number, decimals?: number): number;
345
+ /******************************************************
346
+ * ##: Safe Subtraction
347
+ * Subtracts two numbers with precision normalization and operand validation.
348
+ *
349
+ * Notes:
350
+ * Returns 0 when operands are invalid or on computation errors.
351
+ * Examples: safeSubtract(10, 3.3333, 2) -> 6.67, safeSubtract(5, NaN) -> 0
352
+ * @param {number} a - Minuend
353
+ * @param {number} b - Subtrahend
354
+ * @param {number} decimals - Decimal places for rounding (default 2)
355
+ * History:
356
+ * 01-12-2025: Created
357
+ ****************************************************/
358
+ declare function safeSubtract(a: number, b: number, decimals?: number): number;
359
+ /******************************************************
360
+ * ##: Safe Division
361
+ * Divides two numbers with precision normalization, operand validation, and zero checks.
362
+ *
363
+ * Notes:
364
+ * Returns 0 when operands are invalid or divisor is zero.
365
+ * Examples: safeDivide(1, 3, 3) -> 0.333, safeDivide(10, 0) -> 0
366
+ * @param {number} a - Dividend
367
+ * @param {number} b - Divisor
368
+ * @param {number} decimals - Decimal places for rounding (default 2)
369
+ * History:
370
+ * 01-12-2025: Created
371
+ ****************************************************/
372
+ declare function safeDivide(a: number, b: number, decimals?: number): number;
373
+ /******************************************************
374
+ * ##: Safe Number Comparison
375
+ * Compares two numbers using fixed decimal precision with operand validation.
376
+ *
377
+ * Notes:
378
+ * Returns false when operands are invalid.
379
+ * Examples: numbersEqual(0.1 + 0.2, 0.3) -> true, numbersEqual(NaN, 1) -> false
380
+ * @param {number} a - First number
381
+ * @param {number} b - Second number
382
+ * @param {number} decimals - Decimal places for comparison (default 2)
383
+ * History:
384
+ * 01-12-2025: Created
385
+ ****************************************************/
386
+ declare function numbersEqual(a: number, b: number, decimals?: number): boolean;
317
387
  /**
318
388
  * @deprecated Use `safeParseFloat` instead.
319
389
  */
@@ -324,8 +394,9 @@ declare const toInteger: typeof safeParseInt;
324
394
  *
325
395
  * Notes:
326
396
  * Handles commas as decimal/thousands separators. Returns 0 for null/undefined/empty string or invalid parsing.
327
- * Examples: safeParseFloat("123.45") -> 123.45, safeParseFloat("123,45") -> 123.45, safeParseFloat("1,234.56") -> 1234.56, safeParseFloat("abc", 2) -> 0, safeParseFloat(42) -> 42 * @param {unknown} value - Value to convert
328
- * @param {Number} decimals - Number of decimal places
397
+ * Examples: safeParseFloat("123.45") -> 123.45, safeParseFloat("123,45") -> 123.45, safeParseFloat("1,234.56") -> 1234.56, safeParseFloat("abc", 2) -> 0, safeParseFloat(42) -> 42
398
+ * @param {unknown} value - Value to convert
399
+ * @param {number} decimals - Number of decimal places
329
400
  * History:
330
401
  * 21-08-2025: Created
331
402
  * 29-10-2025: Renamed from toNumber to safeParseFloat
@@ -346,8 +417,8 @@ declare const parseToNumber: typeof safeParseFloat;
346
417
  *
347
418
  * Notes:
348
419
  * Options: length (default 6), charset (default "0123456789"), noLeadingZero (if true, first char not "0"). Returns a string to preserve leading zeros. Uses Web Crypto when possible; otherwise falls back to Math.random().
349
- * @param {Number} length - Number of digits
350
- * @param {Object} options - Options: charset, noLeadingZero
420
+ * @param {number} length - Number of digits
421
+ * @param {object} options - Options: charset, noLeadingZero
351
422
  * History:
352
423
  * 21-08-2025: Created
353
424
  ****************************************************/
@@ -366,7 +437,7 @@ declare const otp: typeof randomDigits;
366
437
  * Intelligently handles European number formats (1.234,56) and US formats (1,234.56).
367
438
  * Converts strings to numbers and applies decimal formatting.
368
439
  * @param {number|string|null|undefined} value Number value to format
369
- * @param {number} decimals Number of decimal places (default: 2)
440
+ * @param {number} decimals - Number of decimal places (default: 2)
370
441
  * @returns {string} Formatted number string with specified decimals
371
442
  * History:
372
443
  * 16-10-2025: Created
@@ -710,4 +781,4 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
710
781
  declare const isBrowser: boolean;
711
782
  declare const isNode: boolean;
712
783
 
713
- export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseFloat, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
784
+ export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.js CHANGED
@@ -185,18 +185,18 @@ function objectToString(obj) {
185
185
  }
186
186
  }
187
187
  }
188
- var isRemovable = (v) => v === null || v === void 0 || v === "null" || v === "undefined";
189
- function cleanObject(obj) {
188
+ var isRemovable = (v, removeEmptyString) => v === null || v === void 0 || v === "null" || v === "undefined" || removeEmptyString && v === "";
189
+ function cleanObject(obj, removeEmptyString = false) {
190
190
  if (Array.isArray(obj)) {
191
- const cleanedArray = obj.map((item) => cleanObject(item)).filter((item) => !isRemovable(item));
191
+ const cleanedArray = obj.map((item) => cleanObject(item, removeEmptyString)).filter((item) => !isRemovable(item, removeEmptyString));
192
192
  return cleanedArray;
193
193
  }
194
194
  if (obj !== null && typeof obj === "object") {
195
195
  const cleaned = {};
196
196
  for (const [key, value] of Object.entries(obj)) {
197
- if (isRemovable(value)) continue;
198
- const nested = cleanObject(value);
199
- if (isRemovable(nested)) continue;
197
+ if (isRemovable(value, removeEmptyString)) continue;
198
+ const nested = cleanObject(value, removeEmptyString);
199
+ if (isRemovable(nested, removeEmptyString)) continue;
200
200
  const isObj = typeof nested === "object" && nested !== null;
201
201
  const isEmptyObj = isObj && !Array.isArray(nested) && Object.keys(nested).length === 0;
202
202
  const isEmptyArr = Array.isArray(nested) && nested.length === 0;
@@ -259,6 +259,61 @@ function safeParseInt(value, defaultValue = 0) {
259
259
  return defaultValue;
260
260
  }
261
261
  }
262
+ function normalizeDecimals(decimals) {
263
+ if (!Number.isFinite(decimals)) return 0;
264
+ const int = Math.floor(decimals);
265
+ if (int < 0) return 0;
266
+ if (int > 100) return 100;
267
+ return int;
268
+ }
269
+ function sanitizeOperands(...values) {
270
+ return values.every((value) => Number.isFinite(value));
271
+ }
272
+ function safeAdd(a, b, decimals = 2) {
273
+ try {
274
+ if (!sanitizeOperands(a, b)) return 0;
275
+ const precision = normalizeDecimals(decimals);
276
+ return Number((a + b).toFixed(precision));
277
+ } catch {
278
+ return 0;
279
+ }
280
+ }
281
+ function safeMultiply(a, b, decimals = 2) {
282
+ try {
283
+ if (!sanitizeOperands(a, b)) return 0;
284
+ const precision = normalizeDecimals(decimals);
285
+ return Number((a * b).toFixed(precision));
286
+ } catch {
287
+ return 0;
288
+ }
289
+ }
290
+ function safeSubtract(a, b, decimals = 2) {
291
+ try {
292
+ if (!sanitizeOperands(a, b)) return 0;
293
+ const precision = normalizeDecimals(decimals);
294
+ return Number((a - b).toFixed(precision));
295
+ } catch {
296
+ return 0;
297
+ }
298
+ }
299
+ function safeDivide(a, b, decimals = 2) {
300
+ try {
301
+ if (!sanitizeOperands(a, b) || b === 0) return 0;
302
+ const precision = normalizeDecimals(decimals);
303
+ return Number((a / b).toFixed(precision));
304
+ } catch {
305
+ return 0;
306
+ }
307
+ }
308
+ function numbersEqual(a, b, decimals = 2) {
309
+ try {
310
+ if (!sanitizeOperands(a, b)) return false;
311
+ const precision = normalizeDecimals(decimals);
312
+ return a.toFixed(precision) === b.toFixed(precision);
313
+ } catch {
314
+ return false;
315
+ }
316
+ }
262
317
  var toInteger = safeParseInt;
263
318
  function safeParseFloat(value, decimals = 6) {
264
319
  try {
@@ -290,7 +345,8 @@ function safeParseFloat(value, decimals = 6) {
290
345
  }
291
346
  const num = parseFloat(normalized);
292
347
  if (!isFinite(num)) return 0;
293
- return Number(num.toFixed(decimals));
348
+ const precision = normalizeDecimals(decimals);
349
+ return Number(num.toFixed(precision));
294
350
  } catch {
295
351
  return 0;
296
352
  }
@@ -1638,6 +1694,6 @@ var assessSecurityRisks = (risks) => {
1638
1694
  var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
1639
1695
  var isNode = typeof process !== "undefined" && !!process.versions?.node;
1640
1696
 
1641
- export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseFloat, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1697
+ export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, 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, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1642
1698
  //# sourceMappingURL=index.js.map
1643
1699
  //# sourceMappingURL=index.js.map