Sha256: 271801d9efaeadf9c1e2e7ff8c77facf5862f6661dbcc434b274c020526536eb

Contents?: true

Size: 883 Bytes

Versions: 19

Compression:

Stored size: 883 Bytes

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.makeStaticFileCache = makeStaticFileCache;

function _fs() {
  const data = _interopRequireDefault(require("fs"));

  _fs = function () {
    return data;
  };

  return data;
}

var _caching = require("../caching");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function makeStaticFileCache(fn) {
  return (0, _caching.makeStrongCache)((filepath, cache) => {
    if (cache.invalidate(() => fileMtime(filepath)) === null) {
      cache.forever();
      return null;
    }

    return fn(filepath, _fs().default.readFileSync(filepath, "utf8"));
  });
}

function fileMtime(filepath) {
  try {
    return +_fs().default.statSync(filepath).mtime;
  } catch (e) {
    if (e.code !== "ENOENT" && e.code !== "ENOTDIR") throw e;
  }

  return null;
}

Version data entries

19 entries across 19 versions & 5 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.18.2 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.2 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.8 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/@babel/core/lib/config/files/utils.js
jester-data-8.0.0 node_modules/@babel/core/lib/config/files/utils.js
ezii-os-5.2.1 node_modules/@babel/core/lib/config/files/utils.js
ezii-os-2.0.1 node_modules/@babel/core/lib/config/files/utils.js
ezii-os-1.1.0 node_modules/@babel/core/lib/config/files/utils.js
ezii-os-1.0.0 node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.7 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js
ezii-os-0.0.0.1.0 node_modules/@babel/core/lib/config/files/utils.js
ezii-os-0.0.0.0.1 node_modules/@babel/core/lib/config/files/utils.js
condenser-0.0.5 lib/condenser/processors/node_modules/@babel/core/lib/config/files/utils.js