node-hledger
Node.js API for hledger.
npm install --save-exact hledger
API
hledger
hledger(args, options)
Invokes hledger and returns a promise. It resolves into the CSV output as a 2D array.
var hledger = 'account' 'balance' 'Assets' '$200' 'Assets:Savings' '$150' 'Assets:Checking' '$50'
You can invoke it with a string:
You can then use functions to make better sense of them:
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
).
'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' // [ { account: 'Savings', amount: '$100' },// { account: 'Checking', amount: '$200' } ]
Used for piping into hledger()
's promise output:
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