加载本地或远程资源
@param   {String}    路径
@return  {Promise}
192786
function(file) {
        this.number++;

        var resource;
        var adapter = this.adapter;
        var resourceCache = adapter.resourceCache;
        var that = this;

        // ignore > map > normalize
        if (adapter.resourceIgnore(file)) {
            return Promise.resolve('');
        }
        file = adapter.resourceMap(file);
        file = this.normalize(file);

        if (this.number > this.adapter.resourceMaxNumber) {
            var errors = new Error('Exceed the maximum load limit on the number of resources');
            errors = new Resource.Error(errors, file);
            return Promise.reject(errors);
        }

        adapter.resourceBeforeLoad(file);

        if (resourceCache && this.cache[file]) {
            resource = this.cache[file];
            if (resource) {
                return resource;
            }
        }


        resource = new Promise(function(resolve, reject) {

            if (that.isRemoteFile(file)) {
                that.loadRemoteFile(file, onload);
            } else {
                that.loadLocalFile(file, onload);
            }

            function onload(errors, data) {
                if (errors) {
                    errors = new Resource.Error(errors, file);
                    reject(errors);
                } else {
                    resolve(data.toString());
                }
            }

        });


        if (resourceCache) {
            this.cache[file] = resource;
        }

        return resource;
    }
931918
function get (u, httpOptions) {
  return new Promise(function (resolve, reject) {
    // console.log('GET', u.href);

    var protocol = u.protocol === "https:" ? https : http;
    var req = protocol.get({
      hostname: u.hostname,
      port: u.port,
      path: u.path,
      auth: u.auth,
      protocol: u.protocol,
      headers: httpOptions.headers || {},
      withCredentials: httpOptions.withCredentials
    });

    if (typeof req.setTimeout === "function") {
      req.setTimeout(httpOptions.timeout);
    }

    req.on("timeout", function () {
      req.abort();
    });

    req.on("error", reject);

    req.once("response", function (res) {
      res.body = new Buffer(0);

      res.on("data", function (data) {
        res.body = Buffer.concat([res.body, new Buffer(data)]);
      });

      res.on("error", reject);

      res.on("end", function () {
        resolve(res);
      });
    });
  });
}
1119338
function (route, parameters) {

        return new Promise((resolve, reject) => {

            request.post({
                url: baseUrl + route,
                qs: parameters
            }, (error, response, body) => {

                if (error) {
                    reject(error);
                } else { resolve('POST sent to ' + baseUrl + route + '\n' + JSON.stringify(parameters)); }
            });
        });
    }
1030417
async function readFiles (locations) {
  return Promise.all(locations.map((location) => {
    return fs.readFile(location, 'utf-8')
  }))
}
112661
function() {
        var self = this;

        return new Promise(function(resolve, reject) {
            var config = {};

            for (var i = 0; i < self._modules.length; i++) {
                var module = self._modules[i];

                var storedModule = config[module.name] = {
                    dependencies: module.dependencies
                };

                if (module.condition) {
                    storedModule.condition = module.condition;
                }

                if (!self._options.ignorePath) {
                    if (module.fullPath) {
                        storedModule.fullPath = upath.toUnix(module.fullPath);
                    } else {
                        var dirname = path.dirname(module.name);

                        var modulePath = module.path || (dirname !== '.' ? dirname + '/' + module.file : module.file);

                        storedModule.path = upath.toUnix(modulePath);
                    }
                }
            }

            resolve(config);
        });
    }
720383
function(){
        var deferred = Q.defer();

        fs.readFile( this.path, "utf-8", function( err, data ){
            if( err ){
                deferred.reject( err );
                return;
            }
            this.srcHTMLCode = data;
            deferred.resolve( this );
        }.bind( this ) );

        return deferred.promise;
    }
981040
function bootstrapPath(dir, site) {
  let promise,
    data = getConfig(dir);

  if (data) {
    promise = load(data, site);
  } else {
    promise = Promise.reject(new Error(`No bootstrap found at ${dir}`));
  }

  return promise;
}
368199
function rimrafPromise(dir) {
  return new Promise((resolve, reject) => {
    rimraf(dir, err => {
      if (err) {
        reject(err);
      } else {
        resolve();
      }
    });
  });
}
126123
function(hoast, filePath, content) {
	return new Promise(function(resolve, reject) {
		hoast.helpers.createDirectory(path.dirname(filePath))
			.then(function() {
				fs.writeFile(filePath, JSON.stringify(content), `utf8`, function(error) {
					if (error) {
						return reject(error);
					}
					resolve();
				});
			})
			.catch(function(error) {
				reject(error);
			});
	});
}
785099
function (providerConstr, args) {
    return new Promise(function (resolve) {
        var instance = new providerConstr();
        addInstanceToStore(args, instance);
        createGetData(instance, args.caller);
        if (args.hasOwnProperty("handler")) {
            instance.setHandler(args.handler);
        }
        if (args.hasOwnProperty("resources")) {
            instance.setResources(args.resources);
        }
        instance.fetchData(resolve, args.caller);
    });
}
281275
function(input, callback, context, remoteData)
  {
    var db = this;
    var promise = new Promise();

    promise.success( callback, context || db );

    function checkModel()
    {
      var result = db.parseModel( input, remoteData );

      if ( result !== false && !promise.isComplete() && db.initialized )
      {
        var remoteLoaded = db.remoteLoaded || !db.hasLoad( Load.All );
        var missingModel = (result === null || !result.$isSaved());
        var lazyLoad = db.hasLoad( Load.Lazy );

        if ( lazyLoad && remoteLoaded && missingModel )
        {
          if ( !result )
          {
            result = db.keyHandler.buildObjectFromKey( db.keyHandler.buildKeyFromInput( input ) );
          }

          result.$once( Model.Events.RemoteGets, function()
          {
            if ( !promise.isComplete() )
            {
              if ( isObject( input ) )
              {
                result.$set( input );
              }

              promise.resolve( result.$isSaved() ? result : null );
            }
          });

          result.$refresh( Cascade.All, db.fetchOptions );
        }
        else
        {
          promise.resolve( result );
        }
      }

      return promise.isComplete() ? false : true;
    }

    if ( checkModel() )
    {
      db.ready( checkModel, db, true );
    }

    return promise;
  }
704858
function () {
				var that = this;

				var oInternalRulesPromise = new Promise(function (resolve) {

					if (that.bCanLoadInternalRules !== null) {
						resolve(that.bCanLoadInternalRules);

						return;
					}


					jQuery.ajax({
						type: "HEAD",
						url: sInternalPingFilePath,
						success: function () {
							that.bCanLoadInternalRules = true;
							resolve(that.bCanLoadInternalRules);
						},
						error: function() {
							that.bCanLoadInternalRules = false;
							resolve(that.bCanLoadInternalRules);
						}
					});
				});

				return oInternalRulesPromise;
			}
537075
function (dirname) {
        return new Promise((resolve, reject) => {
            fs.mkdir(dirname, (err) => {
                if (err) {
                    reject(err);
                }
                else {
                    resolve(dirname);
                }
            });
        });
    }
1181117
function moduleOrPromise(module) {
    if (module instanceof Module) return module;

    if (typeof(module) === 'string') {
      if (modules[module]) return modules[module];
      if (deferredModules[module]) return deferredModules[module].promise;
      if (isGlobal(module)) return modules[module] = new GlobalModule(module);

      /* Half timeout, so this will take precedence on "create(...)" */
      var deferred = new Deferred(globalTimeout / 2, new NoModuleError(module));
      deferredModules[module] = deferred;
      return deferred.promise;
    }

    /* Not a module, not a string... Foo! */
    return Promise.reject("Unable to resolve module of type " + typeof(module));

  }
542541
function load() {
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  params = (0, _lodash.defaults)({}, params, {
    locale: 'en_US'
  });
  return new Promise(function (resolve, reject) {
    if (window.FB) {
      return resolve(window.FB);
    }

    var src = '//connect.facebook.net/' + params.locale + '/sdk.js';
    var script = document.createElement('script');
    script.id = 'facebook-jssdk';
    script.src = src;
    script.async = true;
    script.addEventListener('load', function () {
      return resolve(window.FB);
    }, false);
    script.addEventListener('error', function () {
      return reject('Error loading Facebook JS SDK from ' + src);
    }, false);

    var sibling = document.getElementsByTagName('script')[0];
    sibling.parentNode.insertBefore(script, sibling);
  });
}
1017637
function addQuery(url, query) {
    let urlObj = url_opera.parse(url);
    let urlQue = querystring.parse(urlObj.query);
    query = query || {};
    // 把页面url中的请求参数和数据连接中的请求参数合并
    urlQue = Object.assign({}, query, urlQue);

    // 把合并之后参数进行stringify，作为新的参数
    let queStr = querystring.stringify(urlQue);
    let urlStr = urlObj.protocol + '//' + urlObj.host + urlObj.pathname;

    urlStr += queStr ? ('?' + queStr) : '';

    return urlStr;
  }
683025
function () {
        return {
            /**
             * 是否不存在 placeholder 时候，根据规则自动添加 placeholder
             *
             * @type {boolean}
             */
            autoInsertPlaceholder: true,

            /**
             * 模块加载器文件名
             *
             * @type {Array.<string>}
             */
            loaderScripts: ['require.js', 'esl.js', 'mod.js', 'sea.js', 'system.js'],
	    
            /**
             * 脚本占位符
             *
             * @type {string}
             */
            scriptPlaceholder: '<!--SCRIPT_PLACEHOLDER-->',
	    
            /**
             * 异步脚本占位符
             *
             * @type {string}
             */
            scriptAsyncPlaceholder: '<!--SCRIPT_ASYNC_PLACEHOLDER-->',

            /**
             * 样式占位符
             *
             * @type {string}
             */
            stylePlaceholder: '<!--STYLE_PLACEHOLDER-->',

            /**
             * 资源配置占位符
             *
             * @type {string}
             */
            resourceConfigPlaceholder:
                fis.config.get('placeholder.requireconfig')
                || '<!--RESOURCECONFIG_PLACEHOLDER-->'
        };
    }