Wrapping text for fabric.js

Sometime in 2012 I was looking for a solution to wrapping text in fabric.js. To my dismay nothing existed, so I wrote a quick pure function that will do it. Thanks to charalampos for adding text adjustment capability.   Someone requested a fiddle, so here it is, full code included