@geeebe/common

中文文档
1.0.79发布于 2021/06/14ISCTypeScriptCommonJS近 30 天下载 2049

帮助者

中文使用文档

@geeebe/common

这个库有一点点有用的代码, 加上用于设置一个 typescript 包含一些共同有用设置的工程 ts-node, (中文(简体) ), tslint 财务报告和审定财务报表 jest。 。 。 .

开始

在空工程目录中 .

npm init
# fill in details asked (defaults will do)
npm i @geeebe/common
npx geeebe init

这将为您的工程做以下工作

  • 创建 .editorconfig, (中文(简体) ), .gitignore 财务报告和审定财务报表 .npmignore
  • 安装 typescript 财务报告和审定财务报表 ts-node
  • 安装和配置 tslint
  • 安装 jest 与 ts-jest 创建启动配置
  • 安装和配置 nodemon

要开始,写一些 typescript 代码在 src/index.ts 运行它.

要运行,请使用:

  • npm start 使用 ts-node
  • npm run watch 使用 nodemon 财务报告和审定财务报表 ts-node
  • npm run build 输出到 dist/ 使用 tsc

还有用:

  • npm test 要运行 jest 试验 test/ 目录( 查找) *.test.ts 文档)
  • npm run lint 要运行 tslint

包含代码

这里不多...

HTTP 响应状态

import { Statuses } from '@geeebe/common';

// ...

if (status === Statuses.NOT_FOUND) {} // 404

一些时间和期间的简单功能

import { Time } from '@geeebe/common';

const fiveMinutes = Time.minutes(5); // 5 min in ms = 5 * 60 * 1000
const sevenHours = Time.hours(7); // 7 hours in ms
const someTime = Time.days(2) + Time.hours(3) + Time.seconds(2);

// and then
const hours = Time.toHours(sevenHours);
// etc

// also
const fourHoursAgo = Time.past(Time.hours(4)); // Date() of 4 hours ago
const future = Time.future(Time.seconds(45)); // or in the future

方法:

  • ms(ms: number): Duration
  • seconds(s: number): Duration
  • minutes(m: number): Duration
  • hours(h: number): Duration
  • days(d: number): Duration
  • toMs(d: Duration): number
  • toSeconds(d: Duration): number
  • toMinutes(d: Duration): number
  • toHours(d: Duration): number
  • toDays(d: Duration): number
  • past(interval: Duration): Date
  • future(interval: Duration): Date

常数 :

  • SECOND = 1000
  • MINUTE = 60 * Time.SECOND
  • HOUR = 60 * Time.MINUTE
  • DAY = 24 * Time.HOUR

Async 睡眠函数

await sleep(Time.seconds(45));

版本与发布记录

@geeebe/common 共发布 73 个版本,首次发布于 2018/05/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.79latest2021/06/145 年前
1.0.782021/06/125 年前
1.0.772021/06/125 年前
1.0.762020/12/245 年前
1.0.752020/03/096 年前
1.0.742020/03/056 年前

关于 @geeebe/common 的常见问题

@geeebe/common 是什么?

帮助者

如何安装 @geeebe/common?

在项目目录运行 npm install @geeebe/common,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 geeebe,可以用 npx geeebe 直接运行。

@geeebe/common 支持 TypeScript 吗?

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

@geeebe/common 支持 ESM 还是 CommonJS?

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

@geeebe/common 可以商用吗?

@geeebe/common 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@geeebe/common 的下载量有多少?

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

@geeebe/common 还在维护吗?

最新版本 1.0.79 发布于 2021/06/14(5 年前);至今共发布 73 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/05/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。