Load and define a module
load ( spec Object, Function(callback(err Error)) )
load ( specs Array, Function(callback(err Error)) )
load ( url String, Function(callback(err Error)) )
176158
function load (spec, callback) {
    if ((spec instanceof Array) ||
        Object.prototype.toString.call(spec) === "[object Array]") {
      if (callback) {
        // load multiple and join on callback
        var countdown = spec.length;
        for (var i=0;i<spec.length;++i) {(function(u){
          load(u, function (err) {
            if (err) {
              countdown = 0;
              //throw err;
              callback(err);
            } else if (--countdown === 0) {
              callback();
            }
          });
        })(spec[i]);}
      } else {
        // load multiple (blocking) -- don't use this for network resources
        for (var i=0;i<spec.length;++i) {
          load(spec[i]);
        }
      }
      return;
    } else if (typeof spec === 'string') {
      spec = {url:spec};
    }
    if (!spec.url && spec.id) {
      spec.url = spec.id + '.js';
    } else if (spec.url && !spec.id) {
      var m = /^[^\/]+\/\/[^\/]+\/(.+)$/.exec(spec.url);
      if (m) {
        spec.id = m[1];
      } else {
        spec.id = spec.url;
      }
      spec.id = spec.id.replace(/\.[^\.]+$/, '');
    } else if (!spec.url && !spec.id) {
      throw new TypeError('missing both "url" and "id"');
    }
    // normalize url
    spec.url = normalizeUrl(spec.url, window.location);
    var xhr = new XMLHttpRequest();
    var async = !!callback;
    function evalResponse() {
      try {
        eval('require.define("'+spec.id+'",'+
             ' "'+spec.url.replace(/"/g, '\\"')+'"'+
             ', function (require, module, exports) {'+xhr.responseText+'});');
      } catch (err) {
        err.message += ' in '+spec.url;
        throw err;
      }
    }
    xhr.open('GET', spec.url, async);
    if (async) {
      xhr.onreadystatechange = function (ev) {  
        if (xhr.readyState == 4) {
          if ((xhr.status < 300 && xhr.status >= 200)
            || (xhr.status === 0 && !spec.url.match(/^(?:https?|ftp):\/\//i))) {
            try {
              evalResponse();
              callback(null);
            } catch (err) {
              callback(err);
            }
          } else {
            callback(new Error('failed to load remote module with HTTP'+
                               ' response status '+xhr.status+' '+
                               xhr.responseText));
          }
        }
      };
    }
    xhr.send(null);
    if (!async) {
      evalResponse();
    }
  }
804138
def fetch_or_load(spec_path):
    

    headers = {}

    try:
        modified = datetime.utcfromtimestamp(os.path.getmtime(spec_path))
        date = modified.strftime("%a, %d %b %Y %I:%M:%S UTC")
        headers["If-Modified-Since"] = date
    except OSError as error:
        if error.errno != errno.ENOENT:
            raise

    request = urllib.Request(VALIDATION_SPEC, headers=headers)
    response = urllib.urlopen(request, cafile=certifi.where())

    if response.code == 200:
        with open(spec_path, "w+b") as spec:
            spec.writelines(response)
            spec.seek(0)
            return html.parse(spec)

    with open(spec_path) as spec:
        return html.parse(spec)
911301
def load_module_functions(module):
    
    module_functions = {}

    for name, item in vars(module).items():
        if validator.is_function(item):
            module_functions[name] = item

    return module_functions
1339072
function loadJSON (file, callback) {
  loadText(file, function (err, data) {
    if (err) {
      callback(err, null)
    } else {
      var json = null
      try {
        json = JSON.parse(data)
      } catch (e) {
        return callback(e, null)
      }
      callback(null, json)
    }
  })
}
840120
function _define(/* <exports>, name, dependencies, factory */) {
            var
                // extract arguments
                argv = arguments,
                argc = argv.length,

                // extract arguments from function call - (exports?, name?, modules?, factory)
                exports = argv[argc - 4] || {},
                name = argv[argc - 3] || Math.floor(new Date().getTime() * (Math.random())), // if name is undefined or falsy value we add some timestamp like to name.
                dependencies = argv[argc - 2] || [],
                factory = argv[argc - 1],

                // helper variables
                params = [],
                dependencies_satisfied = true,
                dependency_name,
                result,
                config_dependencies_iterator = 0,
                dependencies_iterator = 0,
                config_dependencies_index = -1;

            if (DEVELOPMENT) {
                _set_debug_timer();
            }

            // config dependecies
            if (_define.prototype.config_dependencies && _define.prototype.config_dependencies.constructor === Array) {
                var config_dependencies = _define.prototype.config_dependencies || [];

                var config_dependencies_size = config_dependencies.length;
                for (; config_dependencies_iterator < config_dependencies_size; config_dependencies_iterator++) {
                    if (name === config_dependencies[config_dependencies_iterator]) {
                        config_dependencies_index = config_dependencies_iterator;
                    }
                }
                if (config_dependencies_index !== -1) {
                    config_dependencies.splice(config_dependencies_index, 1)
                } else {
                    dependencies = dependencies.concat(config_dependencies);
                }
            }

            // find params
            for (; dependencies_iterator < dependencies.length; dependencies_iterator++) {
                dependency_name = dependencies[dependencies_iterator];

                // if this dependency exists, push it to param injection
                if (modules.hasOwnProperty(dependency_name)) {
                    params.push(modules[dependency_name]);
                } else if (dependency_name === 'exports') {
                    params.push(exports);
                } else {
                    if (argc !== 4) { // if 4 values, is reexecuting
                        // no module found. save these arguments for future execution.
                        define_queue[dependency_name] = define_queue[dependency_name] || [];
                        define_queue[dependency_name].push([exports, name, dependencies, factory]);
                    }

                    dependencies_satisfied = false;
                }
            }

            // all dependencies are satisfied, so proceed
            if (dependencies_satisfied) {
                if (!modules.hasOwnProperty(name)) {
                    // execute this module
                    result = factory.apply(this, params);

                    if (result) {
                        modules[name] = result;
                    } else {
                        // assuming result is in exports object
                        modules[name] = exports;
                    }
                }

                // execute others waiting for this module
                while (define_queue[name] && (argv = define_queue[name].pop())) {
                    _define.apply(this, argv);
                }
            }
        }
586392
function define(path, factoryOrObject, options) {
        /*
        $_mod.def('/baz$3.0.0/lib/index', function(require, exports, module, __filename, __dirname) {
            // module source code goes here
        });
        */

        var globals = options && options.globals;

        definitions[path] = factoryOrObject;

        if (globals) {
            var target = win || global;
            for (var i=0;i<globals.length; i++) {
                var globalVarName = globals[i];
                var globalModule = loadedGlobalsByRealPath[path] = requireModule(path);
                target[globalVarName] = globalModule.exports;
            }
        }
    }
347301
function Operation(spec, options, fn) {
  if (typeof options === 'function') {
    fn = [].slice.call(arguments).slice(1);
    options = {};
  } else if (Array.isArray(options)) {
    fn = options;
    options = {};
  } else if (!Array.isArray(fn)) {
    fn = [].slice.call(arguments).slice(2);
  }

  if (!(this instanceof Operation)) {
    return new Operation(spec, options, fn);
  }

  if (typeof spec !== 'object') {
    throw new Error('operation spec must be an object');
  }

  debug('create operation', spec);

  this.spec = spec;
  this.options = options || {};
  this.fn = fn;
  this.middleware = {};
}
442636
function load (arr, fn) {
  function process (i) {
    if (!arr[i]) return fn();
    create(arr[i], function () {
      process(++i);
    });
  };

  process(0);
}
37392
function loadFields(list, callback) {
  list.forEach(loadMethods)

  function loadMethods(field) {
    var module = require('./fields/' + field + '.js')
      , methods

    if (typeof module === 'function' || typeof module === 'string') {
      methods = {}
      methods[field] = module
    }
    else {
      methods = module
    }

    callback(methods)
  }
}
1225486
def require(obj, caller_args=[]):
    
    line, module = get_module_and_line('__spec__')
    src_params = ExpectParams(line, module)

    require_obj = RequireAssert(
        obj,
        src_params=src_params,
        caller_args=caller_args
    )
    _add_expect_to_wrapper(require_obj)
    return require_obj
648524
function(module) {
		var name = module.$modname;
		if (!this.$hasModule(name)) {
			this._modules.push(module);
			if (gui.Type.isFunction(module.oncontextinitialize)) {
				module.oncontextinitialize(window);
			}
			if (gui.Type.isFunction(module.onrun)) {
				module.onrun();
			}
		} else {
			throw new Error(name + ' loaded twice?');
		}
		return module;
	}
1194622
function(callback) {
            var toInit = ['config', 'logger'];
            loader.loadServices(path.resolve(serverRoot, 'services'));
            injectDependencies(loader);

            loader.init(toInit, function(err) {
                callback(err);
            });
        }
1025363
function load(root, path, callback, errback) {
		resolve(root, path, function (realPath, contents) {
			process(realPath, contents, callback, errback);
		}, errback);
	}
1315873
function load(path, callback, errorCallback) {
  try {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", path, true);
    xhr.onreadystatechange = function() {
      if (xhr.readyState === 4) {
        if (xhr.status === 200 || xhr.status === 304) {
          try {
            var response = JSON.parse(xhr.responseText);
            callback(response);
          } catch (e) {
            errorCallback(e);
          }
        } else {
          errorCallback(xhr);
        }
      }
    };
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.send();
  } catch (e) {
    errorCallback(e);
  }
}
828352
def load
      load_source_and_set_module
      module_callbacks if @module
      yield if block_given? # load dependencies
      detect_additions { load_commands } if load_commands?
      set_library_commands
      loaded_correctly? && (@loaded = true)
    end
1275264
function(path, callback) {
        callback = callback || noop;

        //requirejs style
        if(path instanceof Array) {
            return loadArray(path, function() {
                var args = Array.prototype.slice.apply(arguments);

                //delay the callback to match the
                //order of precached and unloaded
                setTimeout(function() {
                    callback.apply(null, args);
                });
            }, [], true);
        }

        // node style
        return acquire.loadPath(path, callback, true);
    }
124060
function loadModule(moduleName, moduleFileName, oxModulesDirPath, options) {
    var Module;
    try {
        Module = require(path.join(oxModulesDirPath, moduleFileName));
    } catch (e) {
        if (e instanceof ModuleUnavailableError) {
            logger.warn('Loading module: ' + moduleName + '. Failed to load - ' + e.message);
            return;
        } else {
            throw e;
        }
    }

    var mod = new Module(options, ctx, resultStore, logger);

    // load external commands
    var cmdDir = path.join(oxModulesDirPath, 'module-' + moduleName, 'commands');
    if (fs.existsSync(cmdDir)) {
        var commandName = null;
        try {
            var files = fs.readdirSync(cmdDir);
            for (var fileName of files) {
                commandName = fileName.slice(0, -3);
                if (commandName.indexOf('.') !== 0) {   // ignore possible hidden files (i.e. starting with '.')
                    var cmdFunc = require(path.join(cmdDir, commandName));
                    // bind function's "this" to module's "this"
                    var fnc = cmdFunc.bind(mod._this || mod);
                    mod[commandName] = fnc;
                    // since commands have access only to _this, reference all
                    // commands on it, so commands could have access to each other.
                    // note that command defined in the main module won't be referenced.
                    mod._this[commandName] = fnc;
                }
            }
        } catch (e) {
            logger.error("Can't load command '" + commandName + ': ' + e.message);
            logger.debug(e.stack);
        }
    }

    // apply this for functions inside 'helpers' methods collection if found
    if (mod.helpers || (mod._this && mod._this.helpers)) {
        var helpers = mod.helpers || mod._this.helpers;
        for (var funcName in helpers) {
            if (typeof helpers[funcName] === 'function') {
                helpers[funcName] = helpers[funcName].bind(mod._this || mod);
            }
        }
    }

    logger.debug('Loading module: ' + moduleName);
    modules[moduleName] = sandbox[moduleName] = global.ox[moduleName] = moduleWrapper(moduleName, mod, resultStore);
}