/* Basically `Module.prototype.load`, but for a buffer instead
of a filepath.
427359
function loadScript(buf, filePath) {
  var submodule = Module._cache[filePath]

  if (!submodule) {
    submodule = new Module(filePath, module)
    submodule.filename = filePath
    submodule.paths = Module._nodeModulePaths(dirname(filePath))
    submodule._compile(String(buf), filePath)
    submodule.loaded = true
    Module._cache[filePath] = submodule
  }

  return submodule.exports
}
857718
function load(file, options = {}) {
	return new Promise((resolve, reject) => {

		// Get file
		var fileName = options.file || file;
		if (!fileName) {
			return reject('Must give a file');
		}

		// Check if file exist
		if (!fs.existsSync(fileName)) {
			return reject(`No such file, ${fileName}`);
		}

		var level     = new Level();
		var firstLine = false;
		var reading   = '';
		var contents  = '';
		var bCount    = 0; // Only used for baddies
		var bInfo     = []; // Only used for baddies
		var rl        = readline.createInterface({
			input: fs.createReadStream(fileName)
		});

		rl.on('line', line => {

			// Check level signature
			if (!firstLine) {
				if (line === 'GRMAP001') return reject(`GMAPs aren't supported at the moment`);
				if (line !== 'GLEVNW01') return reject(`This isn't a level file`);
				firstLine = true;
			}

			// Check if reading for data
			else if (reading) {
				if (line.startsWith(reading)) {
					if (reading === 'SIGNEND') {
						level.signs.last().text = contents.trim();
					} else if (reading === 'NPCEND') {
						level.npcs.last().text = contents.trim();
					} else if (reading === 'BADDYEND') {
						let baddy         = level.baddies.last();
						baddy.attackVerse = bInfo[0];
						baddy.hurtVerse   = bInfo[1];
						baddy.winVerse    = bInfo[2];

						bCount = 0;
						bInfo  = [];
					}

					contents = '';
					reading  = false;
				} else {
					if (reading === 'BADDYEND') {
						bInfo.push(line);
						bCount++;
					} else {
						contents += `${line}\n`;
					}
				}
			}

			// Read tile data
			else if (line.startsWith('BOARD')) {
				let [dataType, startX, startY, width, layerIndex, tilesData] = line.split(' ');

				for (let i = 0; i < width * 2; i += 2) {
					let tileX = startX + i / 2;
					level.tiles.push(new Tile(tileX, startY, layerIndex, tilesData.substr(i, 2)));
				}
			}

			// Links
			else if (line.startsWith('LINK')) {
				let [dataType, targetLevel, sourceX, sourceY, width, height, targetX, targetY] = line.split(' ');

				level.links.push(new Link(sourceX, sourceY, width, height, targetX, targetY, targetLevel));
			}

			// Chest
			else if (line.startsWith('CHEST')) {
				let [dataType, x, y, item, signIndex] = line.split(' ');

				level.chest.push(new Chest(x, y, item, signIndex));
			}

			// Sign
			else if (line.startsWith('SIGN')) {
				let [dataType, x, y] = line.split(' ');

				level.signs.push(new Sign(x, y));
				reading = 'SIGNEND';
			}

			// NPCs
			else if (line.startsWith('NPC')) {
				let [dataType, imageName, x, y] = line.split(' ');

				level.npcs.push(new Npc(x, y, imageName, ''));
				reading = 'NPCEND';
			}

			// Baddies
			else if (line.startsWith('BADDY')) {
				let [dataType, x, y, type] = line.split(' ');

				level.baddies.push(new Baddy(x, y, type));
				reading = 'BADDYEND';
			}

			// Level is fucked up
			else {
				throw new Error(`Can't read line, ${line}`);
			}
		});

		rl.on('close', () => {
			resolve(level);
		});
	});
}
1017278
function (path, image) {

		if (image instanceof Buffer) {
			return Promise.denodeify(PNGImage.loadImage)(image);

		} else if ((typeof path === 'string') && !image) {
			return Promise.denodeify(PNGImage.readImage)(path);

		} else {
			return image;
		}
	}
96008
function loadModule(modulePath) {
    // Setup environment
    if (loadedModule === undefined || loadedModulePath != modulePath) {
        loadedModule = require(modulePath);
        loadedModulePath = modulePath;
        
        return Q(loadedModule);        
    } else {
        return Q(loadedModule);
    }
}
401838
function loadViewModule(path) {
    var Module = module.constructor,
        _module = new Module(path,module);
    _module.load(path);
    return (typeof _module.exports === 'function') ? _module.exports :
        function(context) {
            return extend(_module.exports, context);
        };
}
668556
function loadFromPath(path, container) {
  if (path && typeof path === 'string' && path.length > 0) {
    return load(path, container)
  }
  return Promise.resolve([])
}
1098694
function loadArff(fileName, callback) {
  ARFF.load(fileName, (error, data) => {
    if (error) {
      throw new Error(filename + error);
    }
    callback(data);
  });
  
  return 'THIS IS ASYNCHRONOUS';
}
363515
function loadAPI() {
  var apiPath = this.fullPath(this.paths.api);
  if (fs.existsSync(apiPath) && fs.statSync(apiPath).isDirectory()) {
    var files = protos.util.ls(apiPath, this.regex.jsFile);
    files.forEach(function(file) {
      var methods = protos.require(apiPath + "/" + file, true); // Don't use module cache (allow reloading)
      _.extend(this.api, methods);
    }, this);
  }
  this.emit('api_loaded', this.api);
}
897887
function(callback){
    var argFiles,
        filePath,
        i;

    if(!program.files || program.files.length === 0){
        return callback(null, true);
    }

    argFiles = program.files.split(',');

    output("Loading files...");

    for(i=0; i<argFiles.length; i++){
        filePath = path.resolve(__dirname, argFiles[i].toString());
        output("Reading file..." + filePath);
        if(fs.existsSync(filePath)){
            files.push(fs.readFileSync(filePath));
        }else{
            return callback("File does not exist, " + filePath, false);
        }
    }

    callback(null, true);
}
342010
function loadUses() {
          var globs = Array.prototype.slice.call(arguments, 0);
          var path = require('path');
          utils.forEach(globs, function(patt) {
            var files = glob.sync(patt, {});
            utils.forEach(files, function(file) {
              require(path.join(process.cwd(), file));
            });
          });

          return moduleInstance;
        }
1123419
function load(schema) {
  var obj;
  if (typeof schema == 'string' && schema !== 'null') {
    try {
      obj = JSON.parse(schema);
    } catch (err) {
      // No file loading here.
    }
  }
  if (obj === undefined) {
    obj = schema;
  }
  return obj;
}
361602
function (app) {
  let p = pathUtil.getCronPath(app.getBase(), app.getServerType());
  if (p) {
    return Loader.load(p, app);
  }
}
134056
function loadExtensions() {
  var extsPath = this.fullPath(this.paths.extensions);
  if (fs.existsSync(extsPath) && fs.statSync(extsPath).isDirectory()) {
    var files = protos.util.ls(extsPath, this.regex.jsFile);
    files.forEach(function(file) {
      protos.require(extsPath + "/" + file, true); // Don't use module cache (allow reloading)
    }, this);
  }
  this.emit('exts_loaded');
}
1153914
function loadIconsFromDiskCache (loader, query, cacheFile, fileHash, callback) {
  // Stop if cache is disabled
  if (!query.persistentCache) return callback(null);
  var resolvedCacheFile = path.resolve(loader._compiler.parentCompilation.compiler.outputPath, cacheFile);

  fs.exists(resolvedCacheFile, function (exists) {
    if (!exists) return callback(null);
    fs.readFile(resolvedCacheFile, function (err, content) {
      if (err) return callback(err);
      var cache;
      try {
        cache = JSON.parse(content);
        // Bail out if the file or the option changed
        if (!isCacheValid(cache, fileHash, query)) {
          return callback(null);
        }
      } catch (e) {
        return callback(e);
      }
      callback(null, cache.result);
    });
  });
}
1110207
function (moduleName, modulePath, contents) {
					if (contents.indexOf("require(") < 0) { return contents; }
					if (modules.indexOf(moduleName) < 0) { return contents; }
					var start = "", end = "";
					layers.forEach(function (l) {
						start += "require([\"" + l.name + "\"], function () {\n";
						end += "\n});";
					});
					return contents.replace("require(", start + "require(") + end;
				}
336047
function Reader(buf, filePath) {
  // Allow instantiating without `new`
  if (!(this instanceof Reader)) {
    return new Reader(buf);
  }

  // Allow passing either a path to a file or a raw buffer
  if (typeof buf === 'string') {
    filePath = buf;
    buf = fs.readFileSync(buf);
  }

  // LRU cache that'll hold objects we read from the data section.
  // 5000 seems to be roughly the sweet spot between mem vs hit-rate
  this._pointerCache = new LRU(LRU_SIZE);

  this._buf = buf;

  // Stash the file path for if we want to reload it later
  this.filePath = filePath;

  this.setup();
}
601583
function LoadStatic(filename) {
        var file = G.CommonDir + filename;
        _DebugPath (file)
        return UString.loadFile(file);
    }