@art-suite/art-core-ts-async

中文文档
1.0.1发布于 2026/06/19MITTypeScriptESM + CJS近 30 天下载 3216

Async and Promise utilities for TypeScript

原始使用文档
文档目录6 节
  1. Why This Module?
  2. Example Installation and Use (Required)
  3. Functional Overview
  4. timeout(ms: number, f?: () => unknown): Promise<unknown>
  5. timeoutAt(triggerAtTime: AllDateTypes, f?: () => unknown): …
  6. API Documentation Reference

@art-suite/art-core-ts-async

Essential async utilities for TypeScript, including robust timeout helpers for Promises.

Why This Module?

It makes common async operations more succinct, clearer, and less error-prone—while providing modern, Promise-based alternatives to legacy APIs like setTimeout. This module helps you write more readable and maintainable async code with a simple, type-safe API.

  • timeout: Create a Promise that resolves after a specified delay, optionally running a function after the timeout.
  • timeoutAt: Create a Promise that resolves at a specific time (Date, timestamp, or date string), optionally running a function after the timeout.

Example Installation and Use (Required)

Install with npm:

npm install @art-suite/art-core-ts-async

Basic usage:

import { timeout, timeoutAt } from "@art-suite/art-core-ts-async";

// Wait for 500ms
await timeout(500);

// Wait for 1 second, then run a function
await timeout(1000, () => console.log("done"));

// Wait until a specific time (e.g., 2 seconds from now)
await timeoutAt(Date.now() + 2000);

// Wait until a specific time, then run a function
await timeoutAt(new Date(Date.now() + 1000), () => "finished"); // resolves to "finished"

Functional Overview

timeout(ms: number, f?: () => unknown): Promise<unknown>

Creates a Promise that resolves after a specified number of milliseconds. Optionally, a function can be provided to be called after the timeout. If so, the Promise will resolve with the result of the function.

  • timeout(1000) → resolves after 1 second
  • timeout(500, () => "done") → resolves after 500ms with value "done"

timeoutAt(triggerAtTime: AllDateTypes, f?: () => unknown): Promise<unknown>

Creates a Promise that resolves at a specific time. The time can be a Date, a number (seconds or milliseconds), or a date-time string. Optionally, a function can be provided to be called after the timeout. If so, the Promise will resolve with the result of the function.

  • timeoutAt(Date.now() + 1000) → resolves after 1 second
  • timeoutAt(new Date(Date.now() + 500), () => 42) → resolves after 500ms with value 42

API Documentation Reference

For detailed information on all exported functions and their parameters, please refer to the TypeScript typings and JSDoc comments within the source code.

版本与发布记录

@art-suite/art-core-ts-async 共发布 15 个版本,首次发布于 2025/06/17;过去 12 个月发布了 6 个版本。

版本发布日期距今
1.0.1latest2026/06/194 个月前
1.0.02026/03/297 个月前
0.3.02026/03/277 个月前
0.2.112025/12/0511 个月前
0.2.102025/12/0511 个月前
0.2.92025/12/0411 个月前

关于 @art-suite/art-core-ts-async 的常见问题

@art-suite/art-core-ts-async 是什么?

Async and Promise utilities for TypeScript

如何安装 @art-suite/art-core-ts-async?

在项目目录运行 npm install @art-suite/art-core-ts-async,或使用 pnpm add / yarn add / bun add。

@art-suite/art-core-ts-async 支持 TypeScript 吗?

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

@art-suite/art-core-ts-async 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@art-suite/art-core-ts-async 可以商用吗?

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

@art-suite/art-core-ts-async 的下载量有多少?

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

@art-suite/art-core-ts-async 还在维护吗?

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