• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / glua-api-snippets / 14568966976

21 Apr 2025 06:53AM UTC coverage: 79.51% (+0.2%) from 79.358%
14568966976

Pull #83

github

web-flow
Merge 029806ad2 into 55a61523b
Pull Request #83: Fixing issues in backlog

325 of 405 branches covered (80.25%)

Branch coverage included in aggregate %.

76 of 80 new or added lines in 3 files covered. (95.0%)

9 existing lines in 2 files now uncovered.

1720 of 2167 relevant lines covered (79.37%)

453.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.67
/src/utils/string.ts
1
/**
1✔
2
 * Converts a string to lowerCamelCase
1✔
3
 *
1✔
4
 * @param str The string to convert
1✔
5
 * @returns The converted string
1✔
6
 */
1✔
7
export function toLowerCamelCase(str: string) {
1✔
8
  str = str.replace(/[_-]/g, ' ');
12✔
9
  return str.replace(/(?:^\w|\b\w)/g, (letter, index) => {
12✔
10
    return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
28✔
11
  }).replace(/\s+/g, '');
12✔
12
}
12✔
13

1✔
14
/**
1✔
15
 * Replaces all newlines in a string with spaces
1✔
16
 */
1✔
17
export function removeNewlines(text: string) {
1✔
18
  return text.replace(/\r?\n/g, ' ');
5✔
19
}
5✔
20

1✔
21
/**
1✔
22
 * Puts a comment before each line in a string
1✔
23
 */
1✔
24
export function putCommentBeforeEachLine(text: string, skipLineOne: boolean = true) {
1✔
25
  // Remove duplicate consequitive new lines.
87✔
26
  while (text.match(/\r?\n\r?\n\r?\n/g)) {
87✔
27
    text = text.replace(/\r?\n\r?\n\r?\n/g, "\n\n");
5✔
28
  }
5✔
29

87✔
30
  return text.split(/\r?\n/g).map((line, index) => {
87✔
31
    if (index === 0 && skipLineOne)
170✔
32
      return line;
170✔
33

97✔
34
    line = line.trimEnd();
97✔
35
    let space = line.length > 0 ? ' ' : '';
170✔
36
    return `---${space}${line}`;
170✔
37
  }).join('\n');
87✔
38
}
87✔
39

1✔
40
/**
1✔
41
 * Makes a string safe for use as a file name
1✔
42
 *
1✔
43
 * @param str The string to make safe
1✔
44
 * @param replacement The string to replace unsafe characters with
1✔
45
 * @returns The safe string
1✔
46
 */
1✔
47
export function safeFileName(str: string, replacement: string = '_') {
1✔
48
  return str.replace(/[^a-z0-9_\-\. ]/gi, replacement);
27✔
49
}
27✔
50

1✔
51
/**
1✔
52
 * Escapes all single quotes in a string
1✔
53
 *
1✔
54
 * @param str The string to escape
1✔
55
 * @returns The escaped string
1✔
56
 */
1✔
57
export function escapeSingleQuotes(str: string) {
1✔
NEW
58
  return str.replace(/'/g, '\\\'');
×
NEW
59
}
×
60

1✔
61
/**
1✔
62
 * Indents all lines in a string by a given amount
1✔
63
 *
1✔
64
 * @param text The text to indent
1✔
65
 * @param indent The amount of spaces to indent by
1✔
66
 * @returns The indented text
1✔
67
 */
1✔
68
export function indentText(text: string, indent: number) {
1✔
69
  return text.split('\n').map(line => ' '.repeat(indent) + line).join('\n');
4✔
70
}
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc