Expand description
Beancount WASM Bindings.
This crate provides WebAssembly bindings for using Beancount from JavaScript/TypeScript.
§Features
- Parse Beancount files (single and multi-file with includes)
- Validate ledgers
- Run BQL queries
- Format directives
ParsedLedger— cached single-file with editor features (completions, hover, etc.)Ledger— cached multi-file with queries and cross-file completions
§Example (JavaScript)
import init, { parse, validateSource, query } from '@rustledger/wasm';
await init();
const source = `
2024-01-01 open Assets:Bank USD
2024-01-15 * "Coffee"
Expenses:Food 5.00 USD
Assets:Bank -5.00 USD
`;
const result = parse(source);
if (result.errors.length === 0) {
const validation = validateSource(source);
console.log('Validation errors:', validation.errors);
}Modules§
- convert
- Conversion functions between Beancount types and JSON DTOs.
- types
- Data transfer objects for WASM serialization.
Structs§
- Ledger
- A fully processed multi-file ledger for queries and validation.
- Parsed
Ledger - A parsed and validated single-file ledger with editor features.
Functions§
- balances
- Calculate account balances.
- bql_
completions - Get BQL query completions at cursor position.
- expand_
pads - Process pad directives and expand them.
- format
- Format a Beancount source string.
- hash_
sources - Compute a SHA-256 fingerprint of one or more source strings.
- init
- Initialize the WASM module.
- list_
plugins - List available native plugins.
- parse
- Parse a Beancount source string.
- parse_
multi_ file - Parse multiple Beancount files with include resolution.
- query
- Run a BQL query on a Beancount source string.
- query_
multi_ file - Run a BQL query on multiple Beancount files.
- run_
plugin - Run a single named plugin against a Beancount source and return the resulting directives as JSON.
- validate_
multi_ file - Validate multiple Beancount files with include resolution.
- validate_
source - Validate a Beancount source string.
- version
- Get version information.