source: trip-planner-front/node_modules/hpack.js/tools/utils.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 454 bytes
RevLine 
[6a3a178]1// Wrap lines after 79 chars
2exports.wrap = function wrap(str) {
3 var out = [];
4 var pad = ' ';
5 var line = pad;
6
7 var chunks = str.split(/,/g);
8 chunks.forEach(function(chunk, i) {
9 var append = chunk;
10 if (i !== chunks.length - 1)
11 append += ',';
12
13 if (line.length + append.length > 79) {
14 out.push(line);
15 line = pad;
16 }
17 line += append;
18 });
19 if (line !== pad)
20 out.push(line);
21
22 return out.join('\n');
23};
Note: See TracBrowser for help on using the repository browser.