@baravak/risloo-profile-cli 4.40.3 → 4.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baravak/risloo-profile-cli",
3
- "version": "4.40.3",
3
+ "version": "4.43.0",
4
4
  "description": "**Risloo Profile CLI** is a library for creating profiles, reports and sheets for *psychological* samples.",
5
5
  "main": "bin/risloo.js",
6
6
  "publishConfig": {
@@ -1,28 +1,51 @@
1
1
  // lineWrap Helper
2
2
  // Wrapping Words into Lines
3
3
 
4
- function lineWrap(string, maxChar, options) {
5
- let tokens = string.split(" ");
6
- let lines = [];
7
- let i = 0;
4
+ function lineWrap(str, maxChar) {
5
+ let tokens = str.split(" ");
6
+ let lines = [];
7
+ let i = 0;
8
8
  let L = 0;
9
- while(true) {
10
- let tokenLength = tokens[i].replace(/‌/g, '').length;
11
- L += tokenLength + 1;
9
+
10
+ while (true) {
11
+ if (!tokens[i]) break;
12
+
13
+ let token = tokens[i];
14
+ let tokenLength = token.replace(/‌/g, "").length;
15
+
16
+ if (tokenLength > maxChar) {
17
+ if (i > 0) {
18
+ lines.push(tokens.slice(0, i).join(" ").trim());
19
+ tokens = tokens.slice(i);
20
+ i = 0;
21
+ L = 0;
22
+ continue;
23
+ }
24
+
25
+ lines.push(token.slice(0, maxChar));
26
+ tokens[0] = token.slice(maxChar);
27
+ i = 0;
28
+ L = 0;
29
+ continue;
30
+ }
31
+
32
+ L += tokenLength + 1;
33
+
12
34
  if (L - 1 > maxChar) {
13
- lines.push(tokens.slice(0, i).join(" ").trim());
14
- tokens = tokens.slice(i);
15
- i = 0;
35
+ lines.push(tokens.slice(0, i).join(" ").trim());
36
+ tokens = tokens.slice(i);
37
+ i = 0;
16
38
  L = 0;
17
39
  continue;
18
- } else if (i >= tokens.length - 1) {
19
- lines.push(tokens.slice(0, i + 1).join(" "));
20
- break;
21
- }
22
- i++;
23
- }
24
-
25
- return lines;
40
+ } else if (i >= tokens.length - 1) {
41
+ lines.push(tokens.slice(0, i + 1).join(" "));
42
+ break;
43
+ }
44
+
45
+ i++;
46
+ }
47
+
48
+ return lines;
26
49
  }
27
50
 
28
51
  module.exports = lineWrap;