# @chunkd/source

> Base interface for all sources used by `@chunkd`

Latest version **11.4.1** (published 2026-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chunkd/source
pnpm add @chunkd/source
yarn add @chunkd/source
bun add @chunkd/source
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 11.4.1 |
| Published | 2026-05-23 |
| First published | 2023-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 34.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8 |
| Author | Blayne Chard |
| Maintainers | blacha |

## Links

- npm: https://www.npmjs.com/package/@chunkd/source
- Repository: https://github.com/blacha/chunkd
- Homepage: https://github.com/blacha/chunkd#readme
- Issues: https://github.com/blacha/chunkd/issues
- npm.io page: https://npm.io/package/@chunkd/source

## Recent versions

- 11.4.1 (latest) — 2026-05-23
- 11.4.0 — 2026-03-26
- 11.3.0 — 2026-03-24
- 11.2.0 — 2026-03-03
- 11.1.0 — 2023-08-23
- 11.0.0 — 2023-07-20

## README

# @chunkd/source

Base interface for all sources used by `@chunkd`

````typescript
export interface Source {
  /**
   * human friendly name of the source type
   * @example "aws:s3", "file", "memory"
   */
  type: string;

  /**
   * URL to the source
   *
   * @example "s3://linz-imagery/catalog.json" or "file:///home/blacha/18_126359_137603.webp"
   */
  url: URL;

  /** Metadata about the object the source represents */
  metadata?: SourceMetadata;

  /** Read the metadata before a fetch request */
  head(): Promise<SourceMetadata>;

  /** close the source, sources like files sometimes have open file handles that need to be closed */
  close?(): Promise<void>;

  /**
   * Directly read bytes from the source
   *
   * @example
   * ```typescript
   *  source.fetch(0, 1024) // load the first 1024 bytes
   *  source.fetch(1024, 20) // read 20 bytes at offset 1024
   *  source.fetch(-1024) // load the last 1024 bytes
   *```
   * @param offset Byte to start reading form
   * @param length optional number of bytes to read
   */
  fetch(offset: number, length?: number): Promise<ArrayBuffer>;
}
````

## Examples

Example sources

- [Memory](https://www.npmjs.com/package/@chunkd/source-memory)
- [File](https://www.npmjs.com/package/@chunkd/source-file)
- [AWS](https://www.npmjs.com/package/@chunkd/source-aws)
- [Http](https://www.npmjs.com/package/@chunkd/source-http)

---
_Source: https://npm.io/package/@chunkd/source · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
