Skip to content

Instantly share code, notes, and snippets.

@tilgovi
tilgovi / dom-traversals.coffee
Last active October 8, 2015 00:09
DOM tree traversal helpers
# Return true if the given predicate is true for every Node of the tree.
# The predicate function is invoked once for each Node in the tree.
# An optional third argument specifies a traversal order and should be a
# function that takes a Node and returns its successor. The default order is
# DOM position order (pre-order).
everyNode = (node, fn, next = preFirst) ->
return !someNode(node, ((n) -> !fn(n)), next)
# Return the first Node in the tree that matches the predicate.

Keybase proof

I hereby claim:

  • I am tilgovi on github.
  • I am tilgovi (https://keybase.io/tilgovi) on keybase.
  • I have a public key whose fingerprint is 9255 5CDE B2C1 5E97 0AD8 FDE8 5994 A5A1 8F13 626A

To claim this, I am signing this object: