Synchronously loads a script into the protected Closure context.
@param {string} src Path to the file to load.
161238
function loadScript(src) {
    src = path.normalize(src);
    var contents = fs.readFileSync(src, 'utf8');
    vm.runInContext(contents, closure, src);
  }
879123
function renderTemplateFile(engine, filePath, context) {
    var loader = engine.getLoader();

    // Resolve the filePath
    var resolvedFilePath = loader.resolve(null, filePath);

    return Promise()
    .then(function() {
        if (!loader.async) {
            return loader.getSource(resolvedFilePath);
        }

        var deferred = Promise.defer();
        loader.getSource(resolvedFilePath, deferred.makeNodeResolver());
        return deferred.promise;
    })
    .then(function(result) {
        if (!result) {
            throw error.TemplateError(new Error('Not found'), {
                filename: filePath
            });
        }

        return render(engine, result.path, result.src, context);
    });

}
266926
public static void load(Context cx, Scriptable thisObj,
                            Object[] args, Function funObj)
    {
        for (Object arg : args) {
            String file = Context.toString(arg);
            try {
                Main.processFile(cx, thisObj, file);
            } catch (IOException ioex) {
                String msg = ToolErrorReporter.getMessage(
                        "msg.couldnt.read.source", file, ioex.getMessage());
                throw Context.reportRuntimeError(msg);
            } catch (VirtualMachineError ex) {
                // Treat StackOverflow and OutOfMemory as runtime errors
                ex.printStackTrace();
                String msg = ToolErrorReporter.getMessage(
                        "msg.uncaughtJSException", ex.toString());
                throw Context.reportRuntimeError(msg);
            }
        }
    }
731383
function callbackWrapper() {
					callback && callback.apply( this, arguments );

					// Removed the just loaded script from the queue.
					pending.shift();

					loadNext.call( that );
				}
1369782
function runScriptViaModuleLoader(script, context) {
    if(!fs.existsSync(script.fullPath)) {
        events.emit('warn', 'Script file does\'t exist and will be skipped: ' + script.fullPath);
        return Q();
    }
    var scriptFn = require(script.fullPath);
    context.scriptLocation = script.fullPath;
    context.opts.plugin = script.plugin;

    // We can't run script if it is a plain Node script - it will run its commands when we require it.
    // This is not a desired case as we want to pass context, but added for compatibility.
    if (scriptFn instanceof Function) {
        // If hook is async it can return promise instance and we will handle it.
        return Q(scriptFn(context));
    } else {
        return Q();
    }
}
430391
function ImageNode(src, func, inBrowserCache) {
                this.loaded = undefined;
                this.loading = true;

                if (!inBrowserCache) {
                    this.node = new Image();
                    this.bind(func);
                    this.node.src = src;
                }
                else {
                    this.__onload(func, true);
                }

            }
849462
function reload_file(arg_file_path)
{
	const file_name = path.basename(arg_file_path)
	const this_file_name = path.basename(__filename)
	if (file_name == this_file_name)
	{
		console.info('Need to reload after change on ' + this_file_name)
		return
	}
	
	const exts = ['.js', '.json']
	const ext = path.extname(arg_file_path)
	const full_path = path.resolve(arg_file_path)
	
	if ((exts.indexOf(ext) > -1) && (full_path in require.cache))
	{
		console.info('Reloading: ' + full_path)
		// console.log(require.cache[full_path].parent.children[0])
		
		delete require.cache[full_path]
		require(full_path)
	}
}
164868
function _loadFile(filename, callback) {
    callback = callback || function () { };

    if (filename.charAt(0) == '.') {
      callback();
      return;
    }

    var filepath = path.join(folder, filename);
    fs.readFile(filepath, function (err, data) {
      if (err) {
        console.error('Failed to read file ' + filepath + ' err:', err);
        callback(err);
        return;
      }
      try {
        _loadData(filename, data.toString());
      }
      catch (e) {
        console.info('Object ' + filename + ' was not yet fully written, exception:', e);
        // There will be another notification of change when the last write to file is completed.
        // Meanwhile leave the previous value.
        if (loader) {
          // Store this error to wait until file will be successfully loaded for the 1st time.
          loader.errors[filename] = e;
        }
        // Don't return error to continue asynchronous loading of other files. Errors are assembled on loader.
        callback();
        return;
      }
      console.log('Loaded ' + filename);
      if (loader) {
        if (loader.errors[filename]) {
          // File that previously failed to load, now is loaded.
          delete loader.errors[filename];
          var countErrors = Object.keys(loader.errors).length;
          if (countErrors === 0) {
            // All errors are fixed. This is the time to complete loading.
            var initcb = loader.callback;
            loader = null;
            _updateSingleton();
            initcb();
          }
        }
      }
      callback();
    });
  }
850505
function load (source, options, callback = noop) {
      if (typeof options === 'function') callback = options, options = {}
      options = assign({type: null, encoding: 'base64'}, options)

      // Callback handler
      var contents = window.webContents
      eventcb(contents, 'did-finish-load', 'did-fail-load', callback)

      // Load source as data:
      if (options.type) {
        const data = Buffer.from(source).toString(options.encoding)
        return window.loadURL(`data:${options.type};${options.encoding},${data}`, options)
      }

      // Load source as URL:
      const protocol = url.parse(source).protocol
      if (!protocol) source = 'file://' + source
      return window.loadURL(source, options)
    }
1054030
def _load_script(self, filename: str) -> Script:
        
        with open(path.join(here, 'redis_scripts', filename), mode='rb') as f:
            script_data = f.read()
        rv = self._r.register_script(script_data)
        if script_data.startswith(b'-- idempotency protected script'):
            self._idempotency_protected_scripts.append(rv)
        return rv
1009750
function loadJSConfigFile(filePath) {
    debug(`Loading JS config file: ${filePath}`);
    try {
        return importFresh(filePath);
    } catch (e) {
        debug(`Error reading JavaScript file: ${filePath}`);
        e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
        throw e;
    }
}
316074
function load(source) {
  var redis
    , method
    , script
    , name
    , digest;

  digest = sha1hex(source);
  if(this._cache[digest]) {
    return {script: this._cache[digest], sha: digest};
  }

  name = 'f_' + digest;

  method = util.format(
    'var method = function %s(KEYS, ARGS, cb) {%s}', name, source);

  // declare the method
  try {
    script = vm.createScript(method, name);
  }catch(e) {
    return process.send(
      {
        err: true,
        data: 'error compiling script (new function): user_script: '
          + e.message});
  }

  // cache the method by digest
  this._cache[digest] = script;
  log.debug('script load: %s', digest);
  return {sha: digest, script: script};
}
1104512
function loadJS(src, callback, attrs, timeout, fail, complete) {
    if ($.isObject(src)) {
        callback = src.callback;
        attrs = src.attrs;
        timeout = src.timeout;
        fail = src.fail;
        complete = src.complete;
        src = src.src;
        return loadJS(src, callback, attrs, timeout, fail, complete);
    }
    var script = document.createElement('script');
    var done = false;
    if ($.isObject(attrs)) {
        for (var i in attrs) {
            script.setAttribute(i, attrs[i]);
        }
    }
    var urls = getPath(src);
    src = script.src = urls[0];
    script.async = true;
    script.type = 'text/javascript';
    script.charset = defaultConfig.charset;
    complete = $.isFunction(complete) ? complete : emptyFn;
    script.onload = script.onreadystatechange = function(e) {
        e = e || cleanObj
        if (!done && (e.type === 'load' || /loaded|complete|undefined/.test(script.readyState))) {
            done = true;
            removeNode(script);
            mapLoaded[src] = 'loaded';
            $.isFunction(callback) && callback();
            complete('load');
        }
    };
    script.onerror = function() {
        done = true;
        mapLoaded[src] = 'error';
        $.isFunction(fail) && fail();
        complete('error');
    };
    timeout = $.isNumber(timeout) ? timeout : defaultConfig.timeout;
    if (timeout) {
        setTimeout(function() {
            if (!done) {
                done = true;
                mapLoaded[src] = 'timeout';
                complete('timeout');
            }
        }, timeout);
    }
    mapLoaded[src] = 'pending';
    head.insertBefore(script, base);
    return _;
}
1034370
function create (path, fn) {
  if (scripts[path]) return fn();

  var el = document.createElement('script');
  var loaded = false;

  // debug: loading "%s", path
  el.onload = el.onreadystatechange = function () {
    if (loaded || scripts[path]) return;
    var rs = el.readyState;
    if (!rs || 'loaded' == rs || 'complete' == rs) {
      // debug: loaded "%s", path
      el.onload = el.onreadystatechange = null;
      loaded = true;
      scripts[path] = true;
      fn();
    }
  };

  el.async = 1;
  el.src = path;

  var head = document.getElementsByTagName('head')[0];
  head.insertBefore(el, head.firstChild);
}
348519
function (url) {
      return $.Deferred(function (deferred) {
        var $img = $('<img>');

        $img.one('load', function () {
          $img.off('error abort');
          deferred.resolve($img);
        }).one('error abort', function () {
          $img.off('load').detach();
          deferred.reject($img);
        }).css({
          display: 'none'
        }).appendTo(document.body).attr('src', url);
      }).promise();
    }
893135
function scriptLoader(url, callback) {

			var doc         = document, s = doc.createElement("script")
			  , head        = doc.getElementsByTagName("head")[0]
			  , node
			  , done        = false;
			;

			// On success listener
			function onScriptLoad() {
				if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
				{
					done     = true;
					callback();
				}
			}

			// On failure listener (callback receive an error false)
			function onScriptError() {
				callback(new Error("Packet loading error for " + url));
			}

			// Create the script tag
			node         = document.createElement('script')
			node.type    = config.scriptType || 'text/javascript';
			node.charset = 'utf-8';
			node.async   = true;

			// Listen to the onload event
			if (node.attachEvent &&
					!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
				node.attachEvent('onreadystatechange', onScriptLoad);
			} else {
				node.addEventListener('load', onScriptLoad, false);
				node.addEventListener('error', onScriptError, false);
			}

			// Set the src value with the packed script url
			node.src = url;

			// Start loading by adding the script tag in the head
			head.appendChild(node);

		}
1238362
function loadFile(file, db, callback) { 
    callback = callback || function() {};
    
    if (file.substr(0, 1) !== '/') {
        var parentPath = module.parent.filename.split('/');
        parentPath.pop();
        file = parentPath.join('/') + '/' + file;
    }
    
    load(require(file), db, callback);
}