import _ from 'lodash/fp'
import {tree, isTraversable} from './tree'

export let throws = x => { throw x }
export let tapError = f => (e, ...args) => {
  f(e, ...args)
  throw e
}
export let isNotNil = _.negate(_.isNil)
export let exists = isNotNil
export let isMultiple = x => (x || []).length > 1
export let append = _.curry((x, y) => y + x)

// True for everything except null, undefined, '', [], and {}
export let isBlank = _.overSome([_.isNil, _.isEqual(''), _.isEqual([]), _.isEqual({})])
export let isNotBlank = _.negate(isBlank)
export let isBlankDeep = combinator => x =>
  isBlank(x) ||
  isTraversable(x) &&
    combinator(isBlankDeep(combinator), x)

@@ -35,23 +35,8 @@
 tree
-, isTraversable
 %7D fr
@@ -565,83 +565,41 @@
 %3E%0A  
-isBlank(x) %7C%7C%0A  isTraversable(x) &&%0A    combinator(isBlankDeep(combinator), x)%0A
+combinator(isBlank, tree().leaves(x))

convert isBlankDeep to use tree leaves