# pta-tools

> Plain text accounting journal JS apis

Latest version **1.6.0** (published 2022-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install pta-tools
pnpm add pta-tools
yarn add pta-tools
bun add pta-tools
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2022-11-07 |
| First published | 2021-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 70.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Carlo 'kajyr' |
| Maintainers | kajyr |

## Links

- npm: https://www.npmjs.com/package/pta-tools
- Repository: https://github.com/kajyr/pta-tools
- Homepage: https://github.com/kajyr/pta-tools/tree/main/pta-tools
- Issues: https://github.com/kajyr/pta-tools/issues
- npm.io page: https://npm.io/package/pta-tools

## Dependencies (1)

- [split2](https://npm.io/package/split2.md) ^4.1.0

## Recent versions

- 1.6.0 (latest) — 2022-11-07
- 1.5.2 — 2022-07-13
- 1.5.1 — 2022-01-01
- 1.4.0 — 2021-12-15
- 1.3.0 — 2021-12-14
- 1.2.0 — 2021-12-13
- 1.1.5 — 2021-12-13
- 1.1.4 — 2021-12-13

## README

# Plain text acounting node js api

[![Build Status](https://app.travis-ci.com/kajyr/pta-tools.svg?branch=main)](https://app.travis-ci.com/kajyr/pta-tools)

Plain text accounting JS helpers to interact with the ledger / hledger journal file format.

On the TS / JS side Transactions are described by the [Transaction](pta-tools/src/types.ts) type

## Main APIs

### formatTransaction

```
import { formatTransaction } from 'pta-journal';
```

```
function formatTransaction(trx: Transaction): string
```

Returns the Transaction formatted in a way suitable to be appendend to a journal file

### parse

```
import { parse } from 'pta-tools';
```

```
function parse(stream: ReadableStream): Promise<ParseResult>
```

```
type ParseResult = {
  transactions: Transaction[];
  accounts: string[];
  commodities: string[];
};
```

Returns the transactions, the accounts and the commodities from a journal. To get the stream of the journal you can use

```
const stream = fs.createReadStream('./hledger.journal');
```

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