# @chunkd/core 中文文档

规范地址：https://npmcn.com/package/%40chunkd/core/

版本：10\.3\.0
npm 元数据更新时间：2024-02-07T03:42:47.710Z
中文译文更新时间：2026-11-09T15:37:52.809Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40chunkd/core
原文对照：https://npmcn.com/package/%40chunkd/core/?lang=original
项目主页：https://github.com/blacha/chunkd#readme
源码仓库：https://github.com/blacha/chunkd

弃用说明：Package no longer supported\. Contact Support at https://www\.npmjs\.com/support for more info\.

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：208 kB，58 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：^12\.20\.0 \|\| ^14\.13\.1 \|\| \>=16\.0\.0
- 运行依赖：0 个
- 首次发布：2021-07-21T23:28:54.618Z
- 最新版本发布：2023-05-05T00:09:02.136Z
- 近 30 天下载量：2480（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：24（近 12 个月 0 个）

## 中文简介

将文件分割成块, 然后按需要读取块 .

## 安装

```sh
npm install @chunkd/core
```

也可以使用：`pnpm add @chunkd/core`、`yarn add @chunkd/core`、`bun add @chunkd/core`

## README

# 断开对象读取

将文件分割成块, 然后按需要读取块 .

## 示例来源

-   文件 - [@ chunkd/ source- file (中文(简体) )](https://www.npmjs.com/package/@chunkd/source-file)
-   AWS S3 - (英语) [@ chunkd/ source-aws (原始内容存档于2018-09-31) (英语)](https://www.npmjs.com/package/@chunkd/source-aws)
-   乌尔 - [@ chunkd/ source-url (英语)](https://www.npmjs.com/package/@chunkd/source-url)
-   Google 云号 - [@ chunkd/ source-google-云](https://www.npmjs.com/package/@chunkd/source-google-cloud)
-   记忆 - [@ chunkd/ source-memory (英语)](https://www.npmjs.com/package/@chunkd/source-memory)

### 示例使用

获取数据

```typescript
const source = new SourceUrl('https://example.com/foo')
// Read 1KB chunks
source.chunkSize = 1024;

// Read the first 2KB of the file, or two chunks of data, this will be one HTTP Range requests
if (!source.hasBytes(0, 2048)) await source.loadBytes(0, 2048)

const bytes = source.bytes(0, 2048);
```

同时获取多个区域

```typescript
const source = new SourceUrl('https://example.com/foo')
// Read 1KB chunks
source.chunkSize = 1024;

// Read in the first two KB and 1KB starting at 4KB
// This will do one HTTP Range request for all of the data even though 2048-4096 has not been requested
// Chunks 0 (0-1024), 1 (1024-2048), 2 (2048-3096) 3 (3096-4096) and 4 (4096 - 5120) will be fetched
await Promise.all([
    source.loadBytes(0, 2048), 
    source.loadBytes(4096, 1024)
]) 

const bytes = source.bytes(0, 5120);
```

读取原始字节

```typescript
const source = new SourceUrl('https://example.com/foo')

if (!source.hasBytes(0, 1024)) await source.loadBytes(0, 1024)
// Read a UInt8 starting at offset 0
const firstNumber = source.getUint8(0);
// Read a buffer from offset 10, with length of 100
const firstBuffer = source.bytes(10, 100)
```

## 常见问题

### @chunkd/core 是什么？

将文件分割成块, 然后按需要读取块 \.注意：该包已被作者标记为弃用——Package no longer supported\. Contact Support at https://www\.npmjs\.com/support for more info\.

### 如何安装 @chunkd/core？

在项目目录运行 npm install @chunkd/core，或使用 pnpm add / yarn add / bun add。

### @chunkd/core 支持 TypeScript 吗？

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

### @chunkd/core 支持 ESM 还是 CommonJS？

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

### @chunkd/core 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^12\.20\.0 \|\| ^14\.13\.1 \|\| \>=16\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @chunkd/core 可以商用吗？

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

### @chunkd/core 的下载量有多少？

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

### @chunkd/core 还在维护吗？

最新版本 10\.3\.0 发布于 2023/05/05（3 年前）；至今共发布 24 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/07/22。作者已将其标记为弃用，新项目建议寻找替代方案。

