@chunkd/core

中文文档
10.3.0发布于 2023/05/05MITTypeScriptES Module零依赖近 30 天下载 2480

Split up a file into chunks and then read the chunks as needed.

此软件包已被标记为弃用

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

原始使用文档

Chunked object reading

Split up a file into chunks and then read the chunks as needed.

Example Sources

Example Usage

Fetching Data

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);

Fetching multiple ranges at the same time

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);

Reading raw bytes

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 共发布 24 个版本,首次发布于 2021/07/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
10.3.0latest2023/05/053 年前
10.2.02023/04/283 年前
10.1.12023/01/183 年前
10.1.02023/01/173 年前
10.0.02022/09/224 年前
8.4.02022/06/214 年前

关于 @chunkd/core 的常见问题

@chunkd/core 是什么?

Split up a file into chunks and then read the chunks as needed.注意:该包已被作者标记为弃用——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。作者已将其标记为弃用,新项目建议寻找替代方案。