Javascript-only wordwrap function on whitespace?
<p>Most wordwrap functions I've found are bound to css and/or a browser dom.
I'm working in a javascript environment (rhino) and need to find or design a better word wrap that breaks on whitespace before a given line length value.
My current solution just searches for the last white space before the given character, then clips  the left side, storing it as a line of output (in an array return).  Repeat until no more text remains.</p>

<p>Hoping someone has seen something elegant.</p>
