Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
38
Frontend-Learner/node_modules/eslint-plugin-import-x/lib/utils/module-cache.js
generated
vendored
Normal file
38
Frontend-Learner/node_modules/eslint-plugin-import-x/lib/utils/module-cache.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import debug from 'debug';
|
||||
const log = debug('eslint-plugin-import-x:utils:ModuleCache');
|
||||
export class ModuleCache {
|
||||
constructor(map = new Map()) {
|
||||
this.map = map;
|
||||
}
|
||||
set(cacheKey, result) {
|
||||
this.map.set(cacheKey, {
|
||||
result,
|
||||
lastSeen: process.hrtime(),
|
||||
});
|
||||
log('setting entry for', cacheKey);
|
||||
return result;
|
||||
}
|
||||
get(cacheKey, settings) {
|
||||
const cache = this.map.get(cacheKey);
|
||||
if (cache) {
|
||||
if (process.hrtime(cache.lastSeen)[0] < settings.lifetime) {
|
||||
return cache.result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
log('cache miss for', cacheKey);
|
||||
}
|
||||
}
|
||||
static getSettings(settings) {
|
||||
const cacheSettings = {
|
||||
lifetime: 30,
|
||||
...settings['import-x/cache'],
|
||||
};
|
||||
if (typeof cacheSettings.lifetime === 'string' &&
|
||||
['∞', 'Infinity'].includes(cacheSettings.lifetime)) {
|
||||
cacheSettings.lifetime = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
return cacheSettings;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=module-cache.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue