@articulate/asyncios

中文文档
1.0.3发布于 2025/04/10MITCommonJS近 30 天下载 1.2万

A wrapper for promise-based library Axios into a crocks Async

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录4 节
  1. How to Use
  2. Cancellation
  3. Thanks
  4. The Name

asyncios

A crocks Async wrapper for axios. Allows consumers to take advantage of the "lazy" data type while keeping a familiar API.

How to Use

asyncios accepts the same configuration arguments as the underlying axios function. See the axios documentation for more details.

// GET request
asyncios({ method: 'GET', url: '/user?ID=12345' })
  .fork(
    error => console.log(error),
    response => console.log(response)
  )
// same GET request, but using `params` configuration
asyncios({ method: 'GET', url: '/user', params: { ID: 12345 } })
  .fork(
    error => console.log(error),
    response => console.log(response)
  )
// POST request
asyncios({
  method: 'POST',
  url: '/user?ID=12345',
  data: { firstName: 'Fred', lastName: 'Flinstone' },
})
  .fork(
    error => console.log(error),
    response => console.log(response)
  )

Cancellation

Async-style cancellation is supported. See the crocks doucmentation for more details.

const cancel = asyncios({ method: 'GET', url: '/user?ID=12345' })
  .fork(
    error => console.log(error),
    response => console.log(response),
    () => console.log('cancelled!')
  )

cancel()

axios's cancellation token is also supported. Take note of the different behaviors--while cancelling via crocks will invoke fork's third "cancel" callback, cancelling via axios will invoke fork's first "rejected" callback. See axios's documentation for more details.

const source = axios.CancelToken.source()

asyncios({
  method: 'GET',
  url: '/user?ID=12345',
  cancelToken: source.token
})
  .fork(
    error => {
      if (axios.isCancel(error)) console.log(error.message)
      else { /* handle error */ }
    },
    response => console.log(response)
  )

source.cancel('My cancel message')

Thanks

Thanks to the fine people who work on both axios & crocks.

The Name

Pretty sure is spencerfdavis's fault.

版本与发布记录

@articulate/asyncios 共发布 6 个版本,首次发布于 2019/07/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2025/04/101.6 年前
1.0.12019/08/107 年前
1.0.1-rc22019/08/087 年前
1.0.1-rc12019/08/057 年前
1.0.02019/08/027 年前
1.0.0-rc12019/07/317 年前

关于 @articulate/asyncios 的常见问题

@articulate/asyncios 是什么?

A wrapper for promise-based library Axios into a crocks Async注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @articulate/asyncios?

在项目目录运行 npm install @articulate/asyncios,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:axios(>=0.16.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@articulate/asyncios 支持 TypeScript 吗?

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

@articulate/asyncios 支持 ESM 还是 CommonJS?

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

@articulate/asyncios 可以商用吗?

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

@articulate/asyncios 的下载量有多少?

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

@articulate/asyncios 还在维护吗?

最新版本 1.0.3 发布于 2025/04/10(1.6 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/07/31。作者已将其标记为弃用,新项目建议寻找替代方案。