index.js
function pluginFactory(cache) {

  // ensure cache
  var internalCache = cache || {};

  // create an instance of cache populater
  var getCache = cacheFactory(internalCache);

  // return a closure with a pluginFactory() sidecar
  browserifyIncremental.pluginFactory = pluginFactory;
  return browserifyIncremental;

  /**
   * A browserify plugin that checks incoming file context and uses cached results.
   * @param {object} bundler The browserify bundler instance
   * @param {object} opt An options hash
   */
  function browserifyIncremental(bundler, opt) {
    var isValid = bundler && (typeof bundler === 'object') &&
      (typeof bundler.on === 'function') && (typeof bundler.pipeline === 'object');
    if (isValid) {
      bundler.on('reset', setupPipeline);
      setupPipeline();
    }
    else {
      throw new Error('Expected a browserify bundler instance')
    }

    /**
     * Apply an interceptor to the pipeline.
     */
    function setupPipeline() {
      var deps = bundler.pipeline.get('deps');
      deps.push(getCache(deps._streams[0].cache));
    }
  }
}
function pluginFactory(cache) {

  // ensure cache
  var internalCache = cache || {};

  // create an instance of cache populater
  var getCache = cacheFactory(internalCache);

  // return a closure with a pluginFactory() sidecar
  browserifyIncremental.pluginFactory = pluginFactory;
  return browserifyIncremental;

  /**
   * A browserify plugin that checks incoming file context and uses cached results.
   * @param {object} bundler The browserify bundler instance
   * @param {object} opt An options hash
   */
  function browserifyIncremental(bundler, opt) {
    var isValid = bundler && (typeof bundler === 'object') &&
      (typeof bundler.on === 'function') && (typeof bundler.pipeline === 'object');
    if (isValid) {
      bundler.on('reset', setupPipeline);
      setupPipeline();
    }
    else {
      throw new Error('Expected a browserify bundler instance')
    }

    /**
     * Apply an interceptor to the pipeline.
     */
    function setupPipeline() {
      var deps = bundler.pipeline.get('deps');
      deps.push(getCache(deps._streams[0].cache));
    }
  }
}
function pluginFactory ( cache ) { // ensure cache var internalCache = cache || { } ; // create an instance of cache populater var getCache = cacheFactory ( internalCache ) ; // return a closure with a pluginFactory() sidecar browserifyIncremental . pluginFactory = pluginFactory ; return browserifyIncremental ; /**
   * A browserify plugin that checks incoming file context and uses cached results.
   * @param {object} bundler The browserify bundler instance
   * @param {object} opt An options hash
   */ function browserifyIncremental ( bundler , opt ) { var isValid = bundler && ( typeof bundler === 'object' ) && ( typeof bundler . on === 'function' ) && ( typeof bundler . pipeline === 'object' ) ; if ( isValid ) { bundler . on ( 'reset' , setupPipeline ) ; setupPipeline ( ) ; } else { throw new Error ( 'Expected a browserify bundler instance' ) } /**
     * Apply an interceptor to the pipeline.
     */ function setupPipeline ( ) { var deps = bundler . pipeline . get ( 'deps' ) ; deps . push ( getCache ( deps . _streams [ 0 ] . cache ) ) ; } } }
Create a context for which multiple instances of the plugin may operate with a shared cache.
@param {object} [cache] Optional cache
@returns {function} A browserify plugin
Create a context for which multiple instances of the plugin may operate with a shared cache .