@bugsplat/elfy

中文文档
2.0.0发布于 2025/11/26MITTypeScriptES Module零依赖近 30 天下载 4130

Tiny utility for parsing ELF/SELF files.

原始使用文档
文档目录8 节
  1. Crash and error reporting built for busy developers.
  2. Usage
  3. Browser (with File input)
  4. Browser (with fetch)
  5. Node.js (with FileHandle for large files)
  6. In-memory buffer
  7. Data Sources
  8. 🐛 About

bugsplat-github-banner-basic-outline

BugSplat

Crash and error reporting built for busy developers.


elfy

A tiny utility for parsing ELF/SELF files. Works in both Node.js and browsers.

Usage

  1. Install this package
npm i @bugsplat/elfy
  1. Create an instance of ElfFile by passing a DataSource. The library provides several built-in data sources:

Browser (with File input)

import { ElfFile, BlobDataSource } from '@bugsplat/elfy';

// From a file input element
const file = document.getElementById('file-input').files[0];
const dataSource = new BlobDataSource(file);
const elfFile = new ElfFile(dataSource);

Browser (with fetch)

import { ElfFile, BlobDataSource } from '@bugsplat/elfy';

const response = await fetch('https://example.com/file.elf');
const blob = await response.blob();
const dataSource = new BlobDataSource(blob);
const elfFile = new ElfFile(dataSource);

Node.js (with FileHandle for large files)

import { open } from 'node:fs/promises';
import { ElfFile, DataSource } from '@bugsplat/elfy';

// Create a custom DataSource for Node.js file handles
class FileHandleDataSource implements DataSource {
  constructor(private fileHandle) {}

  async read(offset: number, length: number): Promise<Uint8Array> {
    const buffer = new Uint8Array(length);
    const { bytesRead } = await this.fileHandle.read(buffer, 0, length, offset);
    return buffer.slice(0, bytesRead);
  }
}

const fileHandle = await open('path/to/elf/file', 'r');
try {
  const dataSource = new FileHandleDataSource(fileHandle);
  const elfFile = new ElfFile(dataSource);
  // ... use elfFile
} finally {
  await fileHandle.close();
}

In-memory buffer

import { ElfFile, BufferDataSource } from '@bugsplat/elfy';

// From an ArrayBuffer or Uint8Array already in memory
const dataSource = new BufferDataSource(arrayBuffer);
const elfFile = new ElfFile(dataSource);
  1. Read the contents of a section using readSection. This method throws if the section does not exist.
const contents: Uint8Array = await elfFile.readSection('.note.gnu.build-id');
  1. You can also safely read the contents of a section using tryReadSection.
const { success, section } = await elfFile.tryReadSection('.note.gnu.build-id');

Data Sources

The library uses a DataSource interface to abstract reading bytes from any source:

interface DataSource {
  read(offset: number, length: number): Promise<Uint8Array>;
}

Built-in implementations:

  • BlobDataSource - For browser Blob/File objects. Reads only the requested bytes using Blob.slice().
  • BufferDataSource - For in-memory Uint8Array or ArrayBuffer data.

You can create custom implementations for other sources (e.g., Node.js FileHandle, HTTP range requests, etc.).

🐛 About

BugSplat is a software crash and error reporting service with support for game engines like Unreal Engine, and supports platforms such as PlayStation, Xbox and many more. BugSplat automatically captures critical diagnostic data such as stack traces, log files, and other runtime information. BugSplat also provides automated incident notifications, a convenient dashboard for monitoring trends and prioritizing engineering efforts, and integrations with popular development tools to maximize productivity and ship more profitable software.

版本与发布记录

@bugsplat/elfy 共发布 3 个版本,首次发布于 2024/02/08;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.0latest2025/11/2611 个月前
1.0.12024/03/012 年前
1.0.02024/02/082 年前

关于 @bugsplat/elfy 的常见问题

@bugsplat/elfy 是什么?

Tiny utility for parsing ELF/SELF files.

如何安装 @bugsplat/elfy?

在项目目录运行 npm install @bugsplat/elfy,或使用 pnpm add / yarn add / bun add。

@bugsplat/elfy 支持 TypeScript 吗?

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

@bugsplat/elfy 支持 ESM 还是 CommonJS?

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

@bugsplat/elfy 可以商用吗?

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

@bugsplat/elfy 的下载量有多少?

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

@bugsplat/elfy 还在维护吗?

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