@tometrove/web
v0.0.2
Published
TypeScript library for reading and decoding .tome files
Maintainers
Readme
tome-trove
A TypeScript library for reading and decoding .tome files with full type support.
Installation
npm install tome-troveUsage
import { TomeReader } from "tome-trove";
// Create a new TomeReader instance
const tomeDecoder = new TomeReader("/path/to/chapter.tome");
// Read and parse the tome file
const content = tomeDecoder.read();
// Access parsed data
console.log(content.metadata);
console.log(content.chapters);
// Get raw content
const raw = tomeDecoder.getRawContent();API
TomeReader
The main class for reading tome files.
Constructor
new TomeReader(filePath: string, options?: TomeReaderOptions)filePath: Path to the .tome fileoptions: Optional configurationencoding: File encoding (default: 'utf-8')parseMetadata: Whether to parse metadata (default: true)
Methods
read(): TomeContent- Reads and parses the tome file (cached)getRawContent(): string- Gets raw file content without parsinggetFilePath(): string- Returns the file pathclearCache(): void- Clears cached content
Types
interface TomeContent {
metadata: TomeMetadata;
chapters: TomeChapter[];
rawContent: string;
}
interface TomeChapter {
title: string;
content: string;
metadata?: Record<string, unknown>;
}
interface TomeMetadata {
version?: string;
encoding?: string;
createdAt?: Date;
[key: string]: unknown;
}Development
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm testLicense
ISC
