docs: function define(id, dependencies, factory, _special, _context, _refCount) {
      if (dependencies === undefined) {
        dependencies = [];
        factory = id;
        id = _uid();
      } else if (factory === undefined) {
        factory = dependencies;
        if (toString.call(id) === '[object Array]') {
          dependencies = id;
          id = _uid();
        } else {
          dependencies = [];
        }
      }
  
      // Non-standard: we allow modules to be undefined. This is designed for
      // temporary modules.
      var canceler = { cancel: function(){ _undefine(id); } };
  
      var record = modulesMap[id];
  
      // Nonstandard hack: we call define with null deps and factory, but a
      // non-null reference count (e.g. define('name', null, null, 0, null, 4))
      // when this module is defined elsewhere and we just need to update the
      // reference count. We use this hack to avoid having to expose another
      // global function to increment ref counts.
      if (record) {
        if (_refCount) {
          record.refcount += _refCount;
        }
        // Calling define() on a pre-existing module does not redefine it
        return canceler;
      } else if (!dependencies && !factory && _refCount) {
        // If this module hasn't been defined yet, store the ref count. We'll use
        // it when the module is defined later.
        predefinedRefCounts[id] = (predefinedRefCounts[id] || 0) + _refCount;
        return canceler;
      } else {
        // Defining a new module
        record = { id: id };
        record.refcount = (predefinedRefCounts[id] || 0) + (_refCount || 0);
        delete predefinedRefCounts[id];
      }
  
      if (__DEV__) {
        if (
          !factory ||
          (typeof factory != 'object' && typeof factory != 'function' &&
           typeof factory != 'string')) {
          throw new Error(
            'Invalid factory "' + factory + '" for module "' + id + '". ' +
            'Factory should be either a function or an object.');
        }
  
        if (toString.call(dependencies) !== '[object Array]') {
          throw new Error(
            'Invalid dependencies for module "' + id + '". ' +
            'Dependencies must be passed as an array.');
        }
      }
  
      record.factory = factory;
      record.dependencies = dependencies;
      record.context = _context;
      record.special = _special;
      record.waitingMap = {};
      record.waiting = 0;
      record.hasError = false;
      modulesMap[id] = record;
      _initDependencies(id);
  
      return canceler;
    }