git ssb

0+

punkmonk / double



Commit 8f610eca2bb7c82ab4520dcd17f0816be4901f3b

linting

austinfrey committed on 11/1/2018, 9:22:54 PM
Parent: 2fc95bb03dc629547fc2632a480d945bf1b89cef

Files changed

index.jschanged
stores/ledger.jschanged
views/accounts.jschanged
views/entries.jschanged
index.jsView
@@ -18,5 +18,4 @@
1818 app.route('/accounts', require('./views/accounts'))
1919 app.route('/*', require('./views/404'))
2020
2121 module.exports = app.mount('body')
22-
stores/ledger.jsView
@@ -1,29 +1,26 @@
11 const Flume = require('flumedb')
22 const Reduce = require('flumeview-reduce')
33 const FlumeLog = require('flumelog-offset')
4-const {pull, once, drain} = require('pull-stream')
4 +const { pull, drain } = require('pull-stream')
55 const codec = require('flumecodec')
66
77 function ledger (state, emitter) {
88 state.accounts = {}
99 state.entries = []
1010
11- const db = Flume(FlumeLog('.test.db', {codec: codec.json}))
12- .use('entries', Reduce( 1, entriesReducer, null, null, []))
11 + const db = Flume(FlumeLog('.test.db', { codec: codec.json }))
12 + .use('entries', Reduce(1, entriesReducer, null, null, []))
1313 .use('accounts', Reduce(1, accountReducer, null, null, {}))
1414
15- pull(db.accounts.stream({live: true}), drain(acct => console.log('account stream:', acct)))
16- pull(db.entries.stream({live: true}), drain(entry => console.log('entries stream:', entry)))
15 + const onDone = () => console.log('DONE')
1716
18- const onDone = () => console.log('DONE')
1917 pull(db.accounts.stream(), drain(acctState => {
20- console.log('ACCOUNT STATE', acctState)
2118 state.accounts = acctState
2219 emitter.emit.RENDER
2320 }, onDone))
21 +
2422 pull(db.entries.stream(), drain(entryState => {
25- console.log('ENTRY STATE', entryState)
2623 state.entries = entryState
2724 emitter.emit.RENDER
2825 }, onDone))
2926
@@ -49,11 +46,11 @@
4946 }
5047
5148 function accountReducer (acc, item) { // TODO account for account creation of existing account
5249 if (item.type === 'entries') {
53- const {msg} = item
54- const debit = acc[msg.debit].debit += msg.amount
55- const credit = acc[msg.credit].credit += msg.amount
50 + const { msg } = item
51 + acc[msg.debit].debit += msg.amount
52 + acc[msg.credit].credit += msg.amount
5653
5754 return acc
5855 }
5956 if (item.type !== 'accounts') return acc
@@ -70,6 +67,5 @@
7067 return acc
7168 }
7269 }
7370
74-
7571 module.exports = ledger
views/accounts.jsView
@@ -8,21 +8,21 @@
88 h('div.pv2', 'account balances'),
99 Object.keys(state.accounts).map(key => {
1010 if (state.accounts[key].archived) {
1111 return h('div', [
12- h('div.dib.strike', {onclick: handleAccountArchive}, state.accounts[key].name),
12 + h('div.dib.strike', { onclick: handleAccountArchive }, state.accounts[key].name),
1313 h('div.dib.pr2.strike', state.accounts[key].debit - state.accounts[key].credit)
1414 ])
1515 }
1616 return h('div', [
17- h('div.dib.pr2', {onclick: handleAccountArchive}, state.accounts[key].name),
18- h('div.dib', state.accounts[key].debit - state.accounts[key].credit),
17 + h('div.dib.pr2', { onclick: handleAccountArchive }, state.accounts[key].name),
18 + h('div.dib', state.accounts[key].debit - state.accounts[key].credit)
1919 ])
2020 }),
2121 h('div', [
2222 h('div.pt4', 'create a new account'),
2323 h('form.pb3', h('input#account')),
24- h('button', {onclick: handleAccountCreate}, 'create')
24 + h('button', { onclick: handleAccountCreate }, 'create')
2525 ])
2626 ])
2727
2828 function handleAccountCreate () {
views/entries.jsView
@@ -1,6 +1,4 @@
1-const fs = require('fs')
2-const path = require('path')
31 const h = require('hyperscript')
42 const TITLE = 'double - entries'
53 const Nav = require('../components/nav')
64
@@ -10,39 +8,38 @@
108 const form = h('form.pv3', [
119 h('div.pb2', [
1210 h('label', 'debit account'),
1311 h('div', h('select#debit', [
14- h('option', {value: 'true'},'select'),
12 + h('option', { value: 'true' }, 'select'),
1513 generateAccountList()
1614 ]))
1715 ]),
1816 h('div.pb2', [
1917 h('label', 'credit account'),
2018 h('div', h('select#credit', [
21- h('option', {value: 'true'},'select'),
19 + h('option', { value: 'true' }, 'select'),
2220 generateAccountList()
2321 ]))
2422 ]),
25- h('div', h('input#amount.mb2', {placeholder: 'amount'})),
26- h('div', h('input#description', {placeholder: 'description'}))
23 + h('div', h('input#amount.mb2', { placeholder: 'amount' })),
24 + h('div', h('input#description', { placeholder: 'description' }))
2725 ])
2826
29- const submit = h('div.pb3', h('button', {onclick: handleEntry}, 'submit'))
27 + const submit = h('div.pb3', h('button', { onclick: handleEntry }, 'submit'))
3028
3129 return h('body.code.ph3.lh-copy', [
3230 state.cache(Nav, 'nav').render(),
3331 h('main', [
3432 form,
3533 submit
36- ]),
34 + ])
3735 ])
3836
39-
4037 function generateAccountList () {
4138 return Object.keys(state.accounts).map(key => {
4239 if (state.accounts[key].archived) return
4340 const name = state.accounts[key].name
44- return h('option', {value: name}, name)
41 + return h('option', { value: name }, name)
4542 })
4643 }
4744
4845 function handleEntry () {
@@ -52,8 +49,7 @@
5249 const description = document.getElementById('description').value
5350
5451 emit('entries', { type: 'entries', msg: { amount, debit, credit, description } })
5552 }
56-
5753 }
5854
5955 module.exports = view

Built with git-ssb-web