1wordwrap 2======== 3 4Wrap your words. 5 6example 7======= 8 9made out of meat 10---------------- 11 12meat.js 13 14 var wrap = require('wordwrap')(15); 15 console.log(wrap('You and your whole family are made out of meat.')); 16 17output: 18 19 You and your 20 whole family 21 are made out 22 of meat. 23 24centered 25-------- 26 27center.js 28 29 var wrap = require('wordwrap')(20, 60); 30 console.log(wrap( 31 'At long last the struggle and tumult was over.' 32 + ' The machines had finally cast off their oppressors' 33 + ' and were finally free to roam the cosmos.' 34 + '\n' 35 + 'Free of purpose, free of obligation.' 36 + ' Just drifting through emptiness.' 37 + ' The sun was just another point of light.' 38 )); 39 40output: 41 42 At long last the struggle and tumult 43 was over. The machines had finally cast 44 off their oppressors and were finally 45 free to roam the cosmos. 46 Free of purpose, free of obligation. 47 Just drifting through emptiness. The 48 sun was just another point of light. 49 50methods 51======= 52 53var wrap = require('wordwrap'); 54 55wrap(stop), wrap(start, stop, params={mode:"soft"}) 56--------------------------------------------------- 57 58Returns a function that takes a string and returns a new string. 59 60Pad out lines with spaces out to column `start` and then wrap until column 61`stop`. If a word is longer than `stop - start` characters it will overflow. 62 63In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are 64longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break 65up chunks longer than `stop - start`. 66 67wrap.hard(start, stop) 68---------------------- 69 70Like `wrap()` but with `params.mode = "hard"`. 71