Fix issue #327 Improved compatibility with PHP's wordwrap (#328)
Fix issue #327 Improved compatibility with PHP's wordwrap (#328)

* Fix issue #327 Improved compatibility with PHP's wordwrap

Improved compatilibity with PHP's wordwrap
Made the code a little more readable

* Fix lint issue

kvz/phpjs,kvz/phpjs,kvz/phpjs,kvz/phpjs