@georges-tech/tardis

中文文档
1.2.2发布于 2025/03/07TypeScriptCommonJS近 30 天下载 8457

读取神化数据的时间属性执行

中文使用文档
文档目录4 节
  1. 安装
  2. 使用量
  3. 示例
  4. 特定日期

塔地丝

临时财产 执行情况 读取所显示的数据.

安装

npm install @georges-tech/tardis

使用量

您通过 Tardis 创建服务 createHistoryService 通过提供一系列文档 必须 包含 下列属性:

  /**
   * Date at which the configuration starts to be valid
   */
  effective_date: Date;

  /**
   * Date at which the new configuration has been created
   */
  known_at: Date;

  /**
   * Optional end date for limited time configurations 
   */
  end_date?: Date;

您可以随意添加多少属性, 取决于您的使用大小写, 这些属性会被服务返回 .

文件可包含一个计算公式 end_date,是下一个有效的文件日期,如果它存在。 否则,它 实值 undefined。 。 。 .

在创建服务时,您可以提供相关时间段的工作日期.

示例

import tardis from '@georges-tech/tardis';

const documents = [{
  effective_date: new Date('2020-01-01'),
  known_at: new Date('2020-05-01'),
  data: {
    value: 'old',
  }
}, {
  effective_date: new Date('2020-03-01'),
  known_at: new Date('2020-10-01'),
  data: {
    value: 'new',
  }
}]
const historyService = tardis.createHistoryService({ documents });

const januaryConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-01-03') });
// januaryConfiguration.data.value = 'old'
// januaryConfiguration.end_date = new Date('2020-03-01')

const mayConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-05-03') });
// mayConfiguration.data.value = 'new'
// mayConfiguration.end_date = undefined

特定日期

import tardis from '@georges-tech/tardis';

const documents = [{
  effective_date: new Date('2020-01-01'),
  known_at: new Date('2020-05-01'),
  data: {
    value: 'old',
  }
}, {
  effective_date: new Date('2020-03-01'),
  known_at: new Date('2020-10-01'),
  data: {
    value: 'new',
  },
  {
  effective_date: new Date('2020-04-01'),
  known_at: new Date('2020-12-01'),
  data: {
    value: 'new 2',
  }
}]
const historyService = tardis.createHistoryService({ documents, date: new Date('2020-11-01') });

const januaryConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-01-03') });
// januaryConfiguration.data.value = 'old'
// januaryConfiguration.end_date = new Date('2020-03-01')

const mayConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-05-03') });
// mayConfiguration.data.value = 'new'
// mayConfiguration.end_date = undefined
// Here we keep the configuration known on 01/10 because on the given date we did not yet know the "new2" configuration

版本与发布记录

@georges-tech/tardis 共发布 7 个版本,首次发布于 2020/10/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.2latest2025/03/071.7 年前
1.2.12024/10/092 年前
1.2.02021/05/065 年前
1.1.02021/01/295 年前
1.0.22020/10/206 年前
1.0.12020/10/206 年前

关于 @georges-tech/tardis 的常见问题

@georges-tech/tardis 是什么?

读取神化数据的时间属性执行

如何安装 @georges-tech/tardis?

在项目目录运行 npm install @georges-tech/tardis,或使用 pnpm add / yarn add / bun add。

@georges-tech/tardis 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@georges-tech/tardis 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@georges-tech/tardis 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@georges-tech/tardis 可以商用吗?

@georges-tech/tardis 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@georges-tech/tardis 的下载量有多少?

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

@georges-tech/tardis 还在维护吗?

最新版本 1.2.2 发布于 2025/03/07(1.7 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/10/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。