hledger
Node.js API for hledger.
Last updated 4 years ago by rstacruz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hledger 
SYNC missed versions from official npm registry.

node-hledger

Node.js API for hledger.

npm install --save-exact hledger

Status

API

hledger

hledger(args, options)

Invokes hledger and returns a promise. It resolves into the CSV output as a 2D array.

var hledger = require('hledger')

hledger(['bal', 'Assets'])
  .then((data) => ...)

[ [ 'account', 'balance' ],
  [ 'Assets', '$200' ],
  [ 'Assets:Savings', '$150' ],
  [ 'Assets:Checking', '$50' ] ]

You can invoke it with a string:

hledger('bal Assets')

You can then use functions to make better sense of them:

hledger(['bal', 'Assets'])
  .then(hledger.tableize)
  .then((data) => ...)

[ { account: 'Assets', balance: '$200' },
  { account: 'Assets:Savings', balance: '$150' },
  ... ]

You may pass the option { mode: 'list' } to support commands that don't have CSV output (eg, accounts).

hledger('accounts', { mode: 'list' })
.then(data => ...)

[ 'Assets:Savings',
  'Assets:Checking'
]

hledger.tableize

tableize(list)

hledger.tableize: Turns a CSV-based array into an table list.

input = [
  ['account', 'amount'],
  ['Savings', '$100'],
  ['Checking', '$150']
]

tableize(input)
// [ { account: 'Savings', amount: '$100' },
//   { account: 'Checking', amount: '$200' } ]

Used for piping into hledger()'s promise output:

hledger('...')
  .then(hledger.tableize)
  .then((data) => ...)

Thanks

node-hledger © 2015+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

Current Tags

  • 1.1.1                                ...           latest (4 years ago)

2 Versions

  • 1.1.1                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |