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

de4dn0te / AT00BY10_lib_tests / 23723609914

30 Mar 2026 01:07AM UTC coverage: 96.172% (+96.2%) from 0.0%
23723609914

push

github

de4dn0te
try with c8

203 of 252 branches covered (80.56%)

Branch coverage included in aggregate %.

1430 of 1446 relevant lines covered (98.89%)

2.73 hits per line

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

89.09
/src/toString.js
1
import isSymbol from './isSymbol.js'
1✔
2

1✔
3
/** Used as references for various `Number` constants. */
1✔
4
const INFINITY = 1 / 0
1✔
5

1✔
6
/**
1✔
7
 * Converts `value` to a string. An empty string is returned for `null`
1✔
8
 * and `undefined` values. The sign of `-0` is preserved.
1✔
9
 *
1✔
10
 * @since 4.0.0
1✔
11
 * @category Lang
1✔
12
 * @param {*} value The value to convert.
1✔
13
 * @returns {string} Returns the converted string.
1✔
14
 * @example
1✔
15
 *
1✔
16
 * toString(null)
1✔
17
 * // => ''
1✔
18
 *
1✔
19
 * toString(-0)
1✔
20
 * // => '-0'
1✔
21
 *
1✔
22
 * toString([1, 2, 3])
1✔
23
 * // => '1,2,3'
1✔
24
 */
1✔
25
function toString(value) {
21✔
26
  
21✔
27
  // Exit early for strings to avoid a performance hit in some environments.
21✔
28
  if (typeof value === 'string') {
21✔
29
    return value
12✔
30
  }
12✔
31
  if (Array.isArray(value)) {
21✔
32
    // Recursively convert values (susceptible to call stack limits).
1✔
33
    return `${value.map((other) => other == null ? other : toString(other))}`
1!
34
  }
1✔
35
  if (isSymbol(value)) {
21!
36
    return value.toString()
×
37
  }
×
38
  const result = `${value}`
8✔
39
  return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
21!
40
}
21✔
41

1✔
42
export default toString
1✔
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