@salespark/toolkit 2.1.13 → 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/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)
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)
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} B`;
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) => {