Skip to content

Commit

Permalink
defer validation to evx
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Jun 4, 2019
1 parent dba352d commit 2f03a4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { create } from 'evx'

const isObj = v => typeof v === 'object' && !Array.isArray(v)

const validate = (o, name) => {
if (!isObj(o)) throw name + ' should be an object'
}

// make sure evx and picoapp don't destroy the same events
export function component (create) {
return function initialize (node, ctx) {
Expand Down Expand Up @@ -37,11 +33,10 @@ export function picoapp (components = {}, initialState = {}) {
return evx.getState()
},
add (index) {
validate(index, 'components')
if (!isObj(index)) throw 'components should be an object'
Object.assign(components, index)
},
hydrate (data) {
validate(data, 'state')
return evx.hydrate(data)
},
mount (attrs = 'data-component') {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"microbundle": "^0.11.0"
},
"dependencies": {
"evx": "^1.0.0",
"evx": "^1.0.1",
"picostate": "^1.4.0"
}
}

0 comments on commit 2f03a4a

Please sign in to comment.