@lowentry/utils 1.5.1 → 1.6.2

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.
Files changed (2) hide show
  1. package/LeUtils.js +17 -2
  2. package/package.json +1 -1
package/LeUtils.js CHANGED
@@ -811,6 +811,21 @@ export const LeUtils = {
811
811
  return (a.length < b.length) ? -1 : 1;
812
812
  },
813
813
 
814
+ /**
815
+ * Compares two strings generated by LeUtils.timestamp(). Primarily used for sorting.
816
+ *
817
+ * @param {string} a
818
+ * @param {string} b
819
+ * @returns {number}
820
+ */
821
+ compareTimestampStrings:
822
+ (a, b) =>
823
+ {
824
+ a = LeUtils.base64ToHex(STRING(a).replaceAll('-', '+').replaceAll('_', '/'));
825
+ b = LeUtils.base64ToHex(STRING(b).replaceAll('-', '+').replaceAll('_', '/'));
826
+ return LeUtils.compare(a, b);
827
+ },
828
+
814
829
  /**
815
830
  * Returns true if the given object is empty, false otherwise.
816
831
  *
@@ -1562,7 +1577,7 @@ export const LeUtils = {
1562
1577
  const bytes = new Uint8Array(nowBytes.length + uuid.length);
1563
1578
  bytes.set(nowBytes, 0);
1564
1579
  bytes.set(uuid, nowBytes.length);
1565
- uuid = LeUtils.bytesToBase64(bytes).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
1580
+ uuid = LeUtils.bytesToBase64(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');
1566
1581
 
1567
1582
  return {
1568
1583
  time:now,
@@ -1638,7 +1653,7 @@ export const LeUtils = {
1638
1653
  now = Math.round(now);
1639
1654
  const nowBytes = numberToBytes(now);
1640
1655
 
1641
- return LeUtils.bytesToBase64(nowBytes).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
1656
+ return LeUtils.bytesToBase64(nowBytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');
1642
1657
  };
1643
1658
  })(),
1644
1659
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/utils",
3
- "version": "1.5.1",
3
+ "version": "1.6.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Provides utilities for general JavaScript development.",