@atcute/tid

中文文档
1.1.4发布于 2026/07/160BSDES Module近 30 天下载 7935

atproto timestamp identifier codec library

原始使用文档
文档目录4 节
  1. usage
  2. generating TIDs
  3. parsing TIDs
  4. validating TIDs

@atcute/tid

timestamp identifier (TID) codec for AT Protocol.

npm install @atcute/tid

this library implements atproto's TID codec used to generate compact and unique record keys that can be sorted chronologically.

usage

generating TIDs

import * as TID from '@atcute/tid';

// generate a TID for the current time
const tid = TID.now();
// -> "3l25zusnsfctk"

// create from specific timestamp (microseconds) and clock ID
const custom = TID.create(1724171495793000, 512);
// -> "3l25zusnsfck2"

on Node.js, TID.now() relies on the system's real-time clock for microsecond precision where available, falling back to millisecond precision otherwise.

TID.now() is not monotonic — TIDs encode wall clock time, so the generator must follow clock corrections rather than preserve ordering. enforcing monotonicity on devices with unreliable clocks (e.g. phones) would leave the generator permanently stuck at the wrong time after a correction. the only exception is rapid successive calls within a single process that observe the same timestamp, where it increments instead of reusing it to avoid collisions.

parsing TIDs

import * as TID from '@atcute/tid';

const { timestamp, clockid } = TID.parse('3l25zusnsfctk');
// timestamp: 1724171495793000 (microseconds since epoch)
// clockid: 816

validating TIDs

import * as TID from '@atcute/tid';

TID.validate('3l25zusnsfctk'); // true
TID.validate('invalid'); // false

版本与发布记录

@atcute/tid 共发布 9 个版本,首次发布于 2024/08/18;过去 12 个月发布了 5 个版本。

版本发布日期距今
1.1.4latest2026/07/163 个月前
1.1.32026/06/294 个月前
1.1.22026/02/128 个月前
1.1.12025/12/3010 个月前
1.1.02025/12/2610 个月前
1.0.32025/10/091.1 年前

关于 @atcute/tid 的常见问题

@atcute/tid 是什么?

atproto timestamp identifier codec library

如何安装 @atcute/tid?

在项目目录运行 npm install @atcute/tid,或使用 pnpm add / yarn add / bun add。

@atcute/tid 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/atcute__tid 是否存在。

@atcute/tid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@atcute/tid 可以商用吗?

@atcute/tid 使用 0BSD 许可。几乎没有限制:可自由使用、修改和分发,连保留版权声明也不要求。以上为概括,不构成法律意见,请以许可原文为准。

@atcute/tid 的下载量有多少?

根据 npm 官方下载统计,@atcute/tid 在 2026/10/07 – 2026/11/05 这 30 天内被下载 7,935 次,日均约 265 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atcute/tid 还在维护吗?

最新版本 1.1.4 发布于 2026/07/16(3 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 5 个;首次发布于 2024/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。