TODO make this lower order This is brittle if changes in layer implementation of express
483237
function removeRoutes(app) {
  return function (api, done) {
    if (!api) {
      done(null, false); // no routes to remove
      return
    }

    var removedRoutes = _.remove(app._router.stack, function (layer) {
      if (layer.route == undefined) {
        return false;
      } else {
        return api.matchesRoute(layer.route.path, layer.route.methods);
      }
    });

    if (removedRoutes && removedRoutes.length > 0) {
      console.log(`removed ${removedRoutes.length} routes`);
    }

    done(null, api);
  }
}
642890
function(input, shallow, strict, output) {
    if (shallow && _.every(input, _.isArray)) {
      return concat.apply(output, input);
    }
    for (var i = 0, length = input.length; i < length; i++) {
      var value = input[i];
      if (!_.isArray(value) && !_.isArguments(value)) {
        if (!strict) output.push(value);
      } else if (shallow) {
        push.apply(output, value);
      } else {
        flatten(value, shallow, strict, output);
      }
    }
    return output;
  }
140844
function buildOrderingPartial(requestQuery) {
        var query = [];
        var l = _u.isArray(requestQuery.order) ? requestQuery.order.length : 0;
        for (var fdx = 0; fdx < l; ++fdx) {
            var order = requestQuery.order[fdx],
                column = requestQuery.columns[order.column];

            if (column.orderable === 'true' && column.name) {
                query.push(column.name + " " + order.dir);
            }
        }
        if (query.length)
            return " ORDER BY " + query.join(", ");
        return "";
    }
1278320
function(buffer, req, res, next) {
          var moduleDir = _.find(options.moduleDirs, function(dir) {
            return req.url.indexOf(options.root + dir) === 0;
          });

          // Only process JavaScript that are required modules, this means
          // bailing out early if not in the module path.
          if (!moduleDir || req.url.indexOf(options.root + "vendor") > 0) {
            return next();
          }

          // The module name is just the JavaScript file stripped of the
          // host and location.
          var moduleName = req.url.split(moduleDir)[1];
          moduleName = moduleName.slice(1);

          // I'd rather work with strings here, since buffers aren't widely
          // supported.
          buffer = String(buffer);

          // If ES6 modules are enabled in the configuration, convert by
          // default.
          if (options.es6) {
            buffer = new Compiler(buffer, moduleName.slice(-2, 0)).toAMD();
          }

          // This method allows hooking into the RequireJS toolchain.
          requirejs.tools.useLib(function(require) {
            // Convert to AMD if using CommonJS, by default the conversion
            // will ignore modules that already contain a define.
            require(["commonJs"], function(commonJs) {
              var wrapped = commonJs.convert(moduleName, buffer);
              var noDefine = wrapped.indexOf("define(") === -1;
              var noConfig = wrapped.indexOf("require.config") === -1;

              if (noDefine && noConfig) {
                wrapped = [
                  "define(function(require, exports, module) {",
                    wrapped,
                  "});"
                ].join("\n");
              }

              res.header("Content-type", "application/javascript");
              res.end(wrapped);
            });
          });
        }
1143684
function middlewares() {
        app.middlewares = {}
        const basePath = path.join(app.root, '/middlewares')
        let middlewares = app.config.get('express').middlewares
        if (middlewares && Array.isArray(middlewares) && middlewares.length) {
            for (let m of middlewares) {
                let middleware = require(path.join(basePath, m.dest))(app)
                app.middlewares[m.dest.toLowerCase()] = middleware

                if (middleware.length == 4) { //error handler
                    errorHandlers.push(middleware)
                    continue
                }

                if (m.src)
                    server.use(m.src, wrapper(middleware))
                else
                    server.use(wrapper(middleware))
            }
            if (middlewares.length)
                app.drivers.logger.success('Middleware', 'initialized')
        }
    }
1052534
function lower(str, options, cb) {
  // handle Handlebars or Lodash templates
  if (typeof options === 'function') {
    cb = options;
    options = {};
  }
  cb(null, str.toLowerCase());
}
537592
function bundle () {
  const ordered = order(deps[postcssify.entry], [], {})
  const l = ordered.length
  let ast
  for (let i = 0; i < l; i++) {
    const file = ordered[i]
    const style = styles[file]
    if (style === void 0) {
      return
    } else {
      if (!ast) {
        ast = style.clone()
      } else {
        ast.append(style)
      }
    }
  }
  if (ast) {
    postcss(processors).process(ast.toResult(), { to: dest, map: true }).then((result) => {
      fs.writeFile(dest, result.css, (err) => {
        if (err) {
          throw err
        } else {
          log.info('updated: %s', dest)
        }
      })
    }).catch((err) => log.error(err))
  }
}
1195978
function serve(req, res, next) {
    if (req.method !== 'GET' && req.method !== 'HEAD') return next();

    // surprisingly (bug?) express does not auto-decode req.path
    var reqPath = decodeURI(req.path);

    var file$ = self.file$;

    // try straight match
    var spo = file$[reqPath];

    if (!spo && !/\/$|\.[^/]+$/.test(reqPath)) {

      // try adding trailing / and redirect if found
      if (self.trailingSlash) {
        var redir = reqPath + '/';
        spo = file$[redir];
        if (spo) {
          debug('static redirect %s %s', reqPath, redir);
          return res.redirect(302, redir); // use 302 to avoid browser redir caching
        }
      }

      // try extensions
      if (!spo && self.extensions) {
        for (var i=0; i<self.extensions.length; i++) {
          if ((spo = file$[reqPath + self.extensions[i]])) break;
        }
      }
    }

    if (!spo) return next(); // give up

    if (self.noHtmlExtensions && !path.extname(spo.file)) {
      res.setHeader('Content-Type', 'text/html; charset=utf-8');
    }

    debug('static %s%s', reqPath, (reqPath !== spo.file ? ' -> ' + spo.file : ''));

    var doit = function() { send(req, spo.file, spo.sp.sendOpts).pipe(res); };

    if (spo.sp.delay) return u.delay(doit, u.ms(spo.sp.delay));

    doit();
  }
894563
function () {
                        //noinspection JSReferencingMutableVariableFromClosure
                        res.push({
                            combine: 1,
                            path: prefix + currentComboUrls.join(comboSep) + suffix,
                            mods: currentComboMods
                        });
                    }
1198540
function(handler, priority) {
        if(typeof handler !== 'function') {
          throw new Error('Middleware must be a function.');
        }

        if(typeof priority !== 'undefined') handler.priority = priority;
        _layerList.push(handler);
        return _inst;
      }
740196
function flush(options, callback) {
    if (!options) return callback(new Error('options is required'));
    if (!options.base) return callback(new Error('options.base is required'));
    if (!options.cache) return callback(new Error('options.cache is required'));
    if (!options.layer) return callback(new Error('options.layer is required'));
    if (!options.url) return callback(new Error('options.url is required'));

    var uri = url.parse(options.url);
    if (!uri.protocol) return callback(new Error('Invalid URL: ' + options.url));

    var extname = path.extname(path.basename(uri.pathname));
    var filepath;
    var layerpath;

    switch (extname.toLowerCase()) {
    case '.zip':
    case '.shp':
        layerpath = path.join(options.base, 'layers', options.layer);
        filepath = path.join(options.cache, path.dirname(cachepath(options.url)));
        break;
    default:
        layerpath = path.join(options.base, 'layers', options.layer + extname);
        filepath = path.join(options.cache, cachepath(options.url));
        break;
    }

    Step(function() {
        fs.lstat(layerpath, this);
    }, function removeSymlink(err, stat) {
        if (err && err.code !== 'ENOENT') throw err;
        if (!err && stat.isSymbolicLink()) {
            fs.unlink(layerpath, this);
        } else {
            this();
        }
    }, function removeCache(err) {
        if (err) throw err;
        existsAsync(filepath, function(exists) {
            if (!exists) return this();
            utils.rm(filepath, this);
        }.bind(this));
    }, function removeMetafile(err) {
        if (err) throw err;
        existsAsync(metapath(filepath), function(exists) {
            if (!exists) return this();
            utils.rm(metapath(filepath), this);
        }.bind(this));
    }, function finish(err) {
        callback(err);
    });
}
1017485
function () {
        'use strict';
        var args = Array.prototype.slice.call(arguments);
        args.splice(0, 0, new Date().toISOString());
        console.log.apply(console, args);
    }
367180
function createStack(app) {
  if (!app) {
    throw new Error("Pack-n-stack requires an express/connect app");
  };
  
  app = utils.merge(app, proto);

  Object.defineProperty(app, "count", {
    get: function() {
      return app.stack.length;
    }
  });

  return app;
}
820719
function(opt) {
    var opt = opt || {};

    // required
    this.k = opt.k;
    this.n = opt.n;
    this.alpha = opt.alpha;
    this.beta = opt.beta;

    // computed
    this.out_sx = opt.in_sx;
    this.out_sy = opt.in_sy;
    this.out_depth = opt.in_depth;
    this.layer_type = 'lrn';

    // checks
    if(this.n%2 === 0) { console.log('WARNING n should be odd for LRN layer'); }
  }
773674
function mergeLayers(layers)
{
  var _instance = this
    , result    = null
    ;

  layers.forEach(function(layer)
  {
    layer.exts.forEach(function(ext)
    {
      ext.dirs.forEach(function(cfg)
      {
        // have customizable's array merge function
        result = merge.call({
          useCustomAdapters: merge.behaviors.useCustomAdapters,
          'array': _instance.arrayMerge,
          useCustomTypeOf: merge.behaviors.useCustomTypeOf,
          'typeof': _instance.mergeTypeOf
        }, result || {}, cfg.config);
      });
    });
  });

  // return `null` if noting found
  // and let downstream layers to make the decision
  return result;
}
515823
function() {

        if (this.layers.length == this.map.layers.length) { 
            this.map.events.unregister('addlayer', this, this.configureLayers);

            for(var i=0, len=this.layers.length; i<len; i++) {
                
                var layer = this.map.layers[i];
                var c = this.layers.charAt(i);
                
                if (c == "B") {
                    this.map.setBaseLayer(layer);
                } else if ( (c == "T") || (c == "F") ) {
                    layer.setVisibility(c == "T");
                }
            }
        }
    }
678280
function layerMethod(k, fun) {
    var pos = k.match(position)[0],
        key = k.replace(position, ''),
        prop = this[key];

    if (pos === 'after') {
        this[key] = function () {
            var ret = prop.apply(this, arguments);
            var args = [].slice.call(arguments);
            args.splice(0, 0, ret);
            fun.apply(this, args);
            return ret;
        };
    } else if (pos === 'before') {
        this[key] = function () {
            fun.apply(this, arguments);
            var ret = prop.apply(this, arguments);
            return ret;
        };
    }
}