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

dApY3112 / software-testing-assignment-part2 / 20169881981

12 Dec 2025 02:28PM UTC coverage: 93.827% (-4.2%) from 98.014%
20169881981

push

github

ad1426
Merge branch 'main' of https://github.com/dApY3112/software-testing-assignment-part2

117 of 155 branches covered (75.48%)

Branch coverage included in aggregate %.

947 of 979 relevant lines covered (96.73%)

2.73 hits per line

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

84.91
/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) {
1✔
26
  
3✔
27
  // Exit early for strings to avoid a performance hit in some environments.
3✔
28
  if (typeof value === 'string') {
3✔
29
    return value
2✔
30
  }
2✔
31
  if (Array.isArray(value)) {
3!
32
    // Recursively convert values (susceptible to call stack limits).
×
33
    return `${value.map((other) => other == null ? other : toString(other))}`
×
34
  }
3✔
35
  if (isSymbol(value)) {
3!
36
    return value.toString()
×
37
  }
×
38
  const result = `${value}`
1✔
39
  return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
3!
40
}
1✔
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