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

kulshekhar / ts-jest / 3863036863

pending completion
3863036863

push

github

GitHub
build(deps): bump json5 from 2.2.1 to 2.2.3 in /e2e/transform-js (#3943)

937 of 1054 branches covered (88.9%)

Branch coverage included in aggregate %.

4055 of 4154 relevant lines covered (97.62%)

514.86 hits per line

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

92.06
/src/utils/json.ts
1
/* eslint-disable no-redeclare */
3✔
2
import stableStringify from 'fast-json-stable-stringify'
3✔
3

3✔
4
const UNDEFINED = 'undefined'
3✔
5

3✔
6
export function stringify(input: unknown): string {
491✔
7
  return input === undefined ? UNDEFINED : stableStringify(input)
491✔
8
}
491✔
9

3✔
10
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3✔
11
export function parse(input: string): any {
9✔
12
  return input === UNDEFINED ? undefined : JSON.parse(input)
9✔
13
}
9✔
14

3✔
15
interface NormalizeOptions {
3✔
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3✔
17
  parse?: (input: string) => any
3✔
18
}
3✔
19
/**
3✔
20
 * @internal
3✔
21
 */
3✔
22
export function normalize(input: string, { parse: parser = parse }: NormalizeOptions = {}): string {
12✔
23
  let result: string | undefined
12✔
24
  if (normalize.cache.has(input)) {
12✔
25
    result = normalize.cache.get(input)
3✔
26
  } else {
12✔
27
    const data = parser(input)
9✔
28
    result = stringify(data)
9✔
29
    if (result === input) result = undefined
9!
30
    normalize.cache.set(input, result)
9✔
31
  }
9✔
32

12✔
33
  return result === undefined ? input : result
12!
34
}
12✔
35

3✔
36
/**
3✔
37
 * @internal
3✔
38
 */
3✔
39
// eslint-disable-next-line @typescript-eslint/no-namespace
3✔
40
export namespace normalize {
27✔
41
  export const cache = new Map<string, string | undefined>()
27✔
42
}
27!
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

© 2025 Coveralls, Inc