index.js
function defineGetterFor(depsCache, filename) {

    // instead of making the property re-definable we instead make assignment idempotent
    if (!depsCache.hasOwnProperty(filename)) {
      Object.defineProperty(depsCache, filename, {get: getter});
    }

    // create a getter
    //  we need to use a getter as it is the only hook at which we can perform comparison
    //  the value is accessed multiple times each compile cycle but is only set at the end of the cycle
    //  getters will persist for the life of the internal cache so the test cache also needs to persist
    function getter() {

      // not found
      var cached = internalCache[filename];
      if (!cached) {
        return undefined;
      }
      // we have already tested whether the cached value is valid and deleted it if not
      else if (isTestedCache[filename]) {
        return cached.output;
      }
      // test the input
      else {
        var isMatch = cached.input && fs.existsSync(filename) &&
          (cached.input === fs.readFileSync(filename).toString());
        isTestedCache[filename] = true;
        internalCache[filename] = isMatch && cached;
        return getter();
      }
    }
  }
function defineGetterFor(depsCache, filename) {

    // instead of making the property re-definable we instead make assignment idempotent
    if (!depsCache.hasOwnProperty(filename)) {
      Object.defineProperty(depsCache, filename, {get: getter});
    }

    // create a getter
    //  we need to use a getter as it is the only hook at which we can perform comparison
    //  the value is accessed multiple times each compile cycle but is only set at the end of the cycle
    //  getters will persist for the life of the internal cache so the test cache also needs to persist
    function getter() {

      // not found
      var cached = internalCache[filename];
      if (!cached) {
        return undefined;
      }
      // we have already tested whether the cached value is valid and deleted it if not
      else if (isTestedCache[filename]) {
        return cached.output;
      }
      // test the input
      else {
        var isMatch = cached.input && fs.existsSync(filename) &&
          (cached.input === fs.readFileSync(filename).toString());
        isTestedCache[filename] = true;
        internalCache[filename] = isMatch && cached;
        return getter();
      }
    }
  }
function defineGetterFor ( depsCache , filename ) { // instead of making the property re-definable we instead make assignment idempotent if ( ! depsCache . hasOwnProperty ( filename ) ) { Object . defineProperty ( depsCache , filename , { get : getter } ) ; } // create a getter //  we need to use a getter as it is the only hook at which we can perform comparison //  the value is accessed multiple times each compile cycle but is only set at the end of the cycle //  getters will persist for the life of the internal cache so the test cache also needs to persist function getter ( ) { // not found var cached = internalCache [ filename ] ; if ( ! cached ) { return undefined ; } // we have already tested whether the cached value is valid and deleted it if not else if ( isTestedCache [ filename ] ) { return cached . output ; } // test the input else { var isMatch = cached . input && fs . existsSync ( filename ) && ( cached . input === fs . readFileSync ( filename ) . toString ( ) ) ; isTestedCache [ filename ] = true ; internalCache [ filename ] = isMatch && cached ; return getter ( ) ; } } }
Create getter on first appearance of a given key and operate through the persistent cache objects.
However be careful not to use any closed over variables in the getter.
@param {object} depsCache The browserify cache shared across instances
@param {string} filename The key (file name) for the deps cache
Create getter on first appearance of a given key and operate through the persistent cache objects . However be careful not to use any closed over variables in the getter .