@rljson/rljson 0.0.67 → 0.0.68

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/rljson.js CHANGED
@@ -1636,13 +1636,23 @@ const removeDuplicates = (rljson) => {
1636
1636
  return hip(result, { throwOnWrongHashes: false, updateExistingHashes: true });
1637
1637
  };
1638
1638
  const timeId = () => {
1639
- return nanoid(4) + ":" + Date.now();
1639
+ return Date.now() + ":" + nanoid(4);
1640
1640
  };
1641
1641
  const isTimeId = (id) => {
1642
1642
  const parts = id.split(":");
1643
1643
  if (parts.length !== 2) return false;
1644
- if (isNaN(Number(parts[1]))) return false;
1645
- return parts[0].length === 4;
1644
+ if (isNaN(Number(parts[0]))) return false;
1645
+ return parts[1].length === 4;
1646
+ };
1647
+ const getTimeIdTimestamp = (id) => {
1648
+ if (!isTimeId(id)) return null;
1649
+ const parts = id.split(":");
1650
+ return Number(parts[0]);
1651
+ };
1652
+ const getTimeIdUniquePart = (id) => {
1653
+ if (!isTimeId(id)) return null;
1654
+ const parts = id.split(":");
1655
+ return parts[1];
1646
1656
  };
1647
1657
  const contentTypes = [
1648
1658
  "buffets",
@@ -2518,6 +2528,8 @@ export {
2518
2528
  exampleTableCfg,
2519
2529
  exampleTableCfgTable,
2520
2530
  exampleTypedefs,
2531
+ getTimeIdTimestamp,
2532
+ getTimeIdUniquePart,
2521
2533
  isTimeId,
2522
2534
  isValidFieldName,
2523
2535
  iterateTables,
@@ -15,3 +15,15 @@ export declare const timeId: () => string;
15
15
  * @returns True if the id is a valid TimeId, false otherwise
16
16
  */
17
17
  export declare const isTimeId: (id: string) => boolean;
18
+ /**
19
+ * Extracts the timestamp from a TimeId.
20
+ * @param id - The TimeId string
21
+ * @returns The timestamp in milliseconds since epoch, or null if the id is not a valid TimeId
22
+ */
23
+ export declare const getTimeIdTimestamp: (id: string) => number | null;
24
+ /**
25
+ * Extracts the unique part from a TimeId.
26
+ * @param id - The TimeId string
27
+ * @returns The unique identifier part, or null if the id is not a valid TimeId
28
+ */
29
+ export declare const getTimeIdUniquePart: (id: string) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.67",
3
+ "version": "0.0.68",
4
4
  "description": "The RLJSON data format specification",
5
5
  "homepage": "https://github.com/rljson/rljson",
6
6
  "bugs": "https://github.com/rljson/rljson/issues",
@@ -33,8 +33,8 @@
33
33
  "read-pkg": "^9.0.1",
34
34
  "typescript": "~5.9.3",
35
35
  "typescript-eslint": "^8.46.3",
36
- "vite": "^7.2.0",
37
- "vite-node": "^3.2.4",
36
+ "vite": "^7.2.1",
37
+ "vite-node": "^5.0.0",
38
38
  "vite-plugin-dts": "^4.5.4",
39
39
  "vite-tsconfig-paths": "^5.1.4",
40
40
  "vitest": "^4.0.7",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@rljson/hash": "^0.0.17",
45
- "@rljson/json": "^0.0.22",
45
+ "@rljson/json": "^0.0.23",
46
46
  "nanoid": "^5.1.6"
47
47
  },
48
48
  "scripts": {