source: trip-planner-front/node_modules/less/lib/less-browser/cache.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[6a3a178]1"use strict";
2// Cache system is a bit outdated and could do with work
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.default = (function (window, options, logger) {
5 var cache = null;
6 if (options.env !== 'development') {
7 try {
8 cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;
9 }
10 catch (_) { }
11 }
12 return {
13 setCSS: function (path, lastModified, modifyVars, styles) {
14 if (cache) {
15 logger.info("saving " + path + " to cache.");
16 try {
17 cache.setItem(path, styles);
18 cache.setItem(path + ":timestamp", lastModified);
19 if (modifyVars) {
20 cache.setItem(path + ":vars", JSON.stringify(modifyVars));
21 }
22 }
23 catch (e) {
24 // TODO - could do with adding more robust error handling
25 logger.error("failed to save \"" + path + "\" to local storage for caching.");
26 }
27 }
28 },
29 getCSS: function (path, webInfo, modifyVars) {
30 var css = cache && cache.getItem(path);
31 var timestamp = cache && cache.getItem(path + ":timestamp");
32 var vars = cache && cache.getItem(path + ":vars");
33 modifyVars = modifyVars || {};
34 vars = vars || "{}"; // if not set, treat as the JSON representation of an empty object
35 if (timestamp && webInfo.lastModified &&
36 (new Date(webInfo.lastModified).valueOf() ===
37 new Date(timestamp).valueOf()) &&
38 JSON.stringify(modifyVars) === vars) {
39 // Use local copy
40 return css;
41 }
42 }
43 };
44});
45//# sourceMappingURL=cache.js.map
Note: See TracBrowser for help on using the repository browser.