@ewanc26/tid 1.0.1 → 1.0.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.
- package/README.md +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm add @ewanc26/tid
|
|
|
23
23
|
Pass an ISO 8601 string or a `Date` object. The clock is monotonic — if records arrive out of order, the timestamp is bumped forward so every call produces a strictly increasing TID within the same JS context.
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { generateTID } from '@
|
|
26
|
+
import { generateTID } from '@ewanc26/tid';
|
|
27
27
|
|
|
28
28
|
// From an ISO string (e.g. a Last.fm scrobble timestamp)
|
|
29
29
|
const tid = generateTID('2023-11-01T12:00:00Z');
|
|
@@ -35,7 +35,7 @@ const tid2 = generateTID(new Date('2024-03-15T09:30:00Z'));
|
|
|
35
35
|
### Generate a TID for right now
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import { generateNextTID } from '@
|
|
38
|
+
import { generateNextTID } from '@ewanc26/tid';
|
|
39
39
|
|
|
40
40
|
const tid = generateNextTID();
|
|
41
41
|
```
|
|
@@ -43,7 +43,7 @@ const tid = generateNextTID();
|
|
|
43
43
|
### Validate a TID
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
|
-
import { validateTid } from '@
|
|
46
|
+
import { validateTid } from '@ewanc26/tid';
|
|
47
47
|
|
|
48
48
|
validateTid('3jzfcijpj2z2a'); // true
|
|
49
49
|
validateTid('not-a-tid'); // false
|
|
@@ -52,7 +52,7 @@ validateTid('not-a-tid'); // false
|
|
|
52
52
|
### Decode a TID
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
import { decodeTid } from '@
|
|
55
|
+
import { decodeTid } from '@ewanc26/tid';
|
|
56
56
|
|
|
57
57
|
const { timestampUs, clockId, date } = decodeTid('3jzfcijpj2z2a');
|
|
58
58
|
// timestampUs — microseconds since Unix epoch
|
|
@@ -65,7 +65,7 @@ const { timestampUs, clockId, date } = decodeTid('3jzfcijpj2z2a');
|
|
|
65
65
|
Because the AT Protocol base-32 alphabet is ordered by timestamp, lexicographic string comparison is correct. `compareTids` returns `-1 | 0 | 1` for use as a `sort` comparator.
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
|
-
import { compareTids } from '@
|
|
68
|
+
import { compareTids } from '@ewanc26/tid';
|
|
69
69
|
|
|
70
70
|
const tids = ['3jzfcijpj2z2a', '3jzfabc000022', '3jzfzzzzzzz2a'];
|
|
71
71
|
tids.sort(compareTids);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ewanc26/tid",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Zero-dependency AT Protocol TID generation for Node.js and browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"identifier",
|
|
33
33
|
"lexicon"
|
|
34
34
|
],
|
|
35
|
-
"author": "",
|
|
35
|
+
"author": "Ewan Croft",
|
|
36
36
|
"license": "AGPL-3.0-only",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsup": "^8.5.0",
|