package ledger import ( "github.com/howeyc/ledger" ) type File string func NewFile(p string) (File, error) { f := File(p) _, err := f.Deltas() return f, err } func (file File) Deltas(likes ...Like) ([]Delta, error) { transactions, err := file.transactions() if err != nil { return nil, err } result := make([]Delta, 0, len(transactions)*2) for _, transaction := range transactions { for _, delta := range newDeltas(transaction) { if got := func() bool { for _, like := range likes { if !like(delta) { return false } } return true }(); !got { continue } result = append(result, delta) } } return result, nil } func (file File) transactions() ([]*ledger.Transaction, error) { return ledger.ParseLedgerFile(string(file)) }