mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
Will be used to make sure no default exports are in DevTools. The PRESUBMIT.py has been updated to skip running the formatting check if node_modules files are affected, to workaround crbug.com/1068198. DISABLE_THIRD_PARTY_CHECK=Add plugin to node_modules Bug: 1068198 Change-Id: I04d4dc813daa01099f21d40edf47aaefcc0b045f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2135610 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
'use strict'
|
|
exports.__esModule = true
|
|
|
|
const log = require('debug')('eslint-module-utils:ModuleCache')
|
|
|
|
class ModuleCache {
|
|
constructor(map) {
|
|
this.map = map || new Map()
|
|
}
|
|
|
|
/**
|
|
* returns value for returning inline
|
|
* @param {[type]} cacheKey [description]
|
|
* @param {[type]} result [description]
|
|
*/
|
|
set(cacheKey, result) {
|
|
this.map.set(cacheKey, { result, lastSeen: process.hrtime() })
|
|
log('setting entry for', cacheKey)
|
|
return result
|
|
}
|
|
|
|
get(cacheKey, settings) {
|
|
if (this.map.has(cacheKey)) {
|
|
const f = this.map.get(cacheKey)
|
|
// check freshness
|
|
if (process.hrtime(f.lastSeen)[0] < settings.lifetime) return f.result
|
|
} else log('cache miss for', cacheKey)
|
|
// cache miss
|
|
return undefined
|
|
}
|
|
|
|
}
|
|
|
|
ModuleCache.getSettings = function (settings) {
|
|
const cacheSettings = Object.assign({
|
|
lifetime: 30, // seconds
|
|
}, settings['import/cache'])
|
|
|
|
// parse infinity
|
|
if (cacheSettings.lifetime === '∞' || cacheSettings.lifetime === 'Infinity') {
|
|
cacheSettings.lifetime = Infinity
|
|
}
|
|
|
|
return cacheSettings
|
|
}
|
|
|
|
exports.default = ModuleCache
|