@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/README.md CHANGED
@@ -584,14 +584,17 @@ isNilOrNaN("abc");
584
584
  // Result: true (coerced to NaN)
585
585
  ```
586
586
 
587
- **`formatBytes(bytes: number, si?: boolean, dp?: number): string`** — Formats bytes as human-readable text.
587
+ **`formatBytes(bytes: number, si?: boolean, dp?: number, noSpace?: boolean): string`** — Formats bytes as human-readable text.
588
588
 
589
589
  ```javascript
590
+ formatBytes(999, true);
591
+ // Result: "999 Bytes"
592
+
590
593
  formatBytes(1024);
591
594
  // Result: "1.0 KiB"
592
595
 
593
- formatBytes(1000, true);
594
- // Result: "1.0 kB"
596
+ formatBytes(1000, true, 1, true);
597
+ // Result: "1.0kB"
595
598
  ```
596
599
 
597
600
  **`stringSimilarity(s1: string, s2: string): number`** — Returns the similarity between two strings (0..1).
package/dist/index.cjs CHANGED
@@ -553,11 +553,11 @@ var isNullOrUndefinedInArray = hasNilOrEmpty;
553
553
  var isNullOrUndefinedEmptyOrZero = isNilEmptyOrZeroLen;
554
554
  var isNullUndefinedOrZero = isNilOrZeroLen;
555
555
  var isNullOrUndefinedOrNaN = isNilOrNaN;
556
- var formatBytes = (bytes, si = false, dp = 1) => {
556
+ var formatBytes = (bytes, si = false, dp = 1, noSpace = false) => {
557
557
  if (!Number.isFinite(bytes)) return "NaN";
558
558
  const thresh = si ? 1e3 : 1024;
559
559
  const abs = Math.abs(bytes);
560
- if (abs < thresh) return `${bytes} B`;
560
+ if (abs < thresh) return `${bytes} Bytes`;
561
561
  const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
562
562
  let u = -1;
563
563
  const r = 10 ** dp;
@@ -566,7 +566,7 @@ var formatBytes = (bytes, si = false, dp = 1) => {
566
566
  value /= thresh;
567
567
  ++u;
568
568
  } while (Math.round(Math.abs(value) * r) / r >= thresh && u < units.length - 1);
569
- return `${value.toFixed(dp)} ${units[u]}`;
569
+ return `${value.toFixed(dp)}${noSpace ? "" : " "}${units[u]}`;
570
570
  };
571
571
  var humanFileSize = formatBytes;
572
572
  var levenshtein = (a, b) => {