UNPKG

@shopify/theme-language-server-common

Version:

<h1 align="center" style="position: relative;" > <br> <img src="https://github.com/Shopify/theme-check-vscode/blob/main/images/shopify_glyph.png?raw=true" alt="logo" width="141" height="160"> <br> Theme Language Server </h1>

29 lines 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CachedFileSystem = void 0; class CachedFileSystem { constructor(fs) { this.readFile = cachedByUri(fs.readFile.bind(fs)); this.readDirectory = cachedByUri(fs.readDirectory.bind(fs)); this.stat = cachedByUri(fs.stat.bind(fs)); } } exports.CachedFileSystem = CachedFileSystem; function cachedByUri(fn) { const cache = new Map(); function cached(uri) { if (!cache.has(uri)) { // I'm intentionally leaving this comment here for debugging purposes :) // console.error('cache miss', fn.name, uri); cache.set(uri, fn(uri)); } return cache.get(uri); } cached.invalidate = (uri) => { // I'm intentionally leaving this comment here for debugging purposes :) // console.error('cache invalidate', fn.name, uri); cache.delete(uri); }; return cached; } //# sourceMappingURL=CachedFileSystem.js.map