title: Split JavaScript(nodeJS) string into fixed sized chunks
body: <p>I want to split a string into fixed sized chunks (say 140 characters each) in JavaScript using space as delimiter(i.e it should not break words), <strong>Note: It should handle newline character</strong>
  Currently I'm using wordwrap npm package, but It does not handle new-line character.</p>
  
  <pre><code>var wrap = require('wordwrap')(140)    
  var str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum"
  console.log(wrap(str));
  </code></pre>
  
  <p>It works fine for normal text but if text contains new-line carriage I get following error:<br>
  SyntaxError: Unexpected token ILLEGAL<br>
      at exports.runInThisContext (vm.js:73:16)<br>
      at Module._compile (module.js:443:25)<br>
      at Object.Module._extensions..js (module.js:478:10)<br>
      at Module.load (module.js:355:32)<br>
      at Function.Module._load (module.js:310:12)<br>
      at Function.Module.runMain (module.js:501:10)<br>
      at startup (node.js:129:16)<br>
      at node.js:814:3  </p>