0.1.2 • Published 11 years ago
character-iterator v0.1.2
character-iterator
Iterate through text characters in the DOM tree. Handles parent & sibling relationships.
Installation
Install with component(1):
$ component install matthewmueller/character-iteratorExample
var el = domify('<p>hi<u></u> there, <strong>cowboy <em>dude</em>!</strong>!</p>');
var it = iterator(el.querySelector('em'), 2)
assert('d' == it.next());
assert('e' == it.next());
assert('!' == it.next());
assert('!' == it.next());API
iterator(el, [offset], [root])
Get the next character in the DOM starting at el with offset. If offset isn't specified it starts at 0. You can also set an optional root to contain the iterator.
iterator#next()
Move on to the next character. If at the end, return null.
iterator#prev()
Move on to the previous character. If at the end, return null.
Test
npm install component-test
make testLicense
MIT