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

benmosher / eslint-plugin-import / #28399472

pending completion
#28399472

push

GitHub
<a href="https://github.com/benmosher/eslint-plugin-import/commit/<a class=hub.com/benmosher/eslint-plugin-import/commit/79ad37dfbf90869a29029b2bc556bd6108018c99">79ad37dfb<a href="https://github.com/benmosher/eslint-plugin-import/commit/79ad37dfbf90869a29029b2bc556bd6108018c99">">Merge </a><a class="double-link" href="https://github.com/benmosher/eslint-plugin-import/commit/<a class="double-link" href="https://github.com/benmosher/eslint-plugin-import/commit/44e85782da066487a4a5f5a62ae9b8d0c1d55aff">44e85782d</a>">44e85782d</a><a href="https://github.com/benmosher/eslint-plugin-import/commit/79ad37dfbf90869a29029b2bc556bd6108018c99"> into 4a9be6384">4a9be6384</a>

1363 of 1848 branches covered (73.76%)

1677 of 2595 relevant lines covered (64.62%)

38.84 hits per line

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

0.0
/utils/ModuleCache.js
1
'use strict';
2
exports.__esModule = true;
×
3

4
const log = require('debug')('eslint-module-utils:ModuleCache');
×
5

6
class ModuleCache {
7
  constructor(map) {
8
    this.map = map || new Map();
×
9
  }
10

11
  /**
12
   * returns value for returning inline
13
   * @param {[type]} cacheKey [description]
14
   * @param {[type]} result   [description]
15
   */
16
  set(cacheKey, result) {
17
    this.map.set(cacheKey, { result, lastSeen: process.hrtime() });
×
18
    log('setting entry for', cacheKey);
×
19
    return result;
×
20
  }
21

22
  get(cacheKey, settings) {
23
    if (this.map.has(cacheKey)) {
×
24
      const f = this.map.get(cacheKey);
×
25
      // check freshness
26
      if (process.hrtime(f.lastSeen)[0] < settings.lifetime) return f.result;
×
27
    } else log('cache miss for', cacheKey);
×
28
    // cache miss
29
    return undefined;
×
30
  }
31

32
}
33

34
ModuleCache.getSettings = function (settings) {
×
35
  const cacheSettings = Object.assign({
×
36
    lifetime: 30,  // seconds
37
  }, settings['import/cache']);
38

39
  // parse infinity
40
  if (cacheSettings.lifetime === '∞' || cacheSettings.lifetime === 'Infinity') {
×
41
    cacheSettings.lifetime = Infinity;
×
42
  }
43

44
  return cacheSettings;
×
45
};
46

47
exports.default = ModuleCache;
×
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