3.1.1 • Published 8 months ago

@atcute/car v3.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@atcute/car

lightweight DASL CAR (content-addressable archives) and atproto repository decoder library for AT Protocol.

usage

streaming usage

import { CarReader, RepoReader } from '@atcute/car/v4';

const stream = new ReadableStream({
	/* ... */
});

// read AT Protocol repository exports
{
	await using repo = RepoReader.fromStream(stream);

	for await (const entry of repo) {
		entry;
		// ^? RepoEntry { collection: 'app.bsky.feed.post', rkey: '3lprcc55bb222', ... }
	}

	repo.missingBlocks;
	//   ^? []
}

// read generic CAR archives
{
	await using car = CarReader.fromStream(stream);

	const roots = await car.roots();

	for await (const entry of car) {
		entry;
		// ^? CarEntry { cid: CidLink {}, bytes: Uint8Array {}, ... }
	}
}

streaming usage (for runtimes without await using yet)

const repo = RepoReader.fromStream(stream);

try {
	for await (const entry of repo) {
		entry;
		// ^? RepoEntry
	}
} finally {
	await repo.dispose();
}

sync usage

const buffer = Uint8Array.from([
	/* ... */
]);

// read AT Protocol repository exports
{
	const repo = RepoReader.fromUint8Array(buffer);

	for (const entry of repo) {
		entry;
		// ^? RepoEntry { collection: 'app.bsky.feed.post', rkey: '3lprcc55bb222', ... }
	}

	repo.missingBlocks;
	//   ^? []
}

// read generic CAR archives
{
	const car = CarReader.fromUint8Array(buffer);

	const roots = car.roots;

	for (const entry of car) {
		entry;
		// ^? CarEntry { cid: CidLink {}, bytes: Uint8Array {}, ... }
	}
}
3.0.4

9 months ago

1.1.1

1 year ago

3.0.3

9 months ago

3.1.1

8 months ago

3.0.2

10 months ago

3.1.0

8 months ago

3.0.1

10 months ago

3.0.5

9 months ago

3.0.0

10 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.1.0

11 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago