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

hexojs / hexo-util / 16626368405

30 Jul 2025 03:06PM UTC coverage: 68.03% (-28.8%) from 96.875%
16626368405

Pull #426

github

web-flow
Merge a039b3b6e into d497bc760
Pull Request #426: build: support both ESM and CommonJS

611 of 790 branches covered (77.34%)

1117 of 1626 new or added lines in 36 files covered. (68.7%)

116 existing lines in 2 files now uncovered.

3758 of 5524 relevant lines covered (68.03%)

64.46 hits per line

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

92.59
/lib/cache.ts
1
export class Cache<T> {
1✔
2
  cache: Map<string, T>;
6✔
3

6✔
4
  constructor() {
6✔
5
    this.cache = new Map();
6✔
6
  }
6✔
7

6✔
8
  set(id: string, value: T) {
6✔
9
    this.cache.set(id, value);
92✔
10
  }
92✔
11

6✔
12
  has(id: string) {
6✔
13
    return this.cache.has(id);
103✔
14
  }
103✔
15

6✔
16
  get(id: string) {
6✔
17
    return this.cache.get(id);
7✔
18
  }
7✔
19

6✔
20
  del(id: string) {
6✔
21
    this.cache.delete(id);
1✔
22
  }
1✔
23

6✔
24
  apply(id: string, value): T {
6✔
25
    if (this.has(id)) return this.get(id);
93✔
26

87✔
27
    if (typeof value === 'function') value = value();
93✔
28

87✔
29
    this.set(id, value);
87✔
30
    return value;
87✔
31
  }
87✔
32

6✔
33
  flush() {
6✔
34
    this.cache.clear();
1✔
35
  }
1✔
36

6✔
37
  size() {
6✔
38
    return this.cache.size;
2✔
39
  }
2✔
40

6✔
41
  dump() {
6✔
42
    return Object.fromEntries(this.cache);
1✔
43
  }
1✔
44
}
6✔
45

1✔
46

1✔
47
// For ESM compatibility
1✔
48
export default Cache;
1✔
49
// For CommonJS compatibility
1✔
50
if (typeof module !== 'undefined' && typeof module.exports === 'object' && module.exports !== null) {
1!
NEW
51
  module.exports = Cache;
×
NEW
52
  // For ESM compatibility
×
NEW
53
  module.exports.default = Cache;
×
NEW
54
}
×
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