當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Q.default函數代碼示例

本文整理匯總了TypeScript中Q.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

            return function (result:service.LogInResult):Q.IPromise<model.HttpResponse> {
                switch (result.type) {
                    case service.LogInResultType.Success:
                        request.user = result.user;
                        return onSuccess(request);

                    case service.LogInResultType.Rejection:
                        return Q(new model.HttpResponse(403, { "code": "Forbidden", "message": result.reason }));

                    case service.LogInResultType.Failure:
                        return Q(new model.HttpResponse(401, { "code": "Unauthorized", "message": result.reason }));

                    default:
                        return Q(new model.HttpResponse(500, { "code": "InternalServerError" }));
                }
            }
開發者ID:MorleyDev,項目名稱:zander.server,代碼行數:16,代碼來源:AuthenticationServiceImpl.ts

示例2: pipelineFunction

export default function pipelineFunction(event?: gulp.WatchEvent) {

    if (event !== undefined) {
        if (event.type !== 'deleted') {
            return q();
        }

        const files: string[] = [
            event.path.replace(/\\/g, '/').replace('.ts', '.js'),
            event.path.replace(/\\/g, '/').replace('.ts', '.js.map'),
            event.path.replace(/\\/g, '/').replace('.jade', '.html'),
            event.path.replace(/\\/g, '/').replace('.sass', '.css')
        ];

        return del(files, { force: true });
    } else {
        const files: string[] = [
            new FilePath(root.application.path(), '/**/*.js').toString(),
            new FilePath(root.application.path(), '/**/*.js.map').toString(),
            root.application.views.files().toString(),
            new FilePath(root.application.path(), '/**/*.css').toString()
        ];


        return del(files, { force: true });
    }
};
開發者ID:ibzakharov,項目名稱:angular_project_template,代碼行數:27,代碼來源:purge.ts

示例3: Q

                        .then((result:data.AuthenticationResult):Q.IPromise<LogInResult> => {
                            if (result.success) {
                                if (minAuthLevel > model.AuthenticationLevel.User)
                                    return Q(new LogInResult(LogInResultType.Rejection, "Do not possess required permission level", undefined));

                                return Q(new LogInResult(LogInResultType.Success, undefined, new model.UserLogin(result.username, model.AuthenticationLevel.User, result.userid)));
                            }
                            return Q(new LogInResult(LogInResultType.Failure, result.reason, undefined));
                        });
開發者ID:MorleyDev,項目名稱:zander.server,代碼行數:9,代碼來源:AuthenticationServiceImpl.ts

示例4: Q

                            .then((authorised:service.AuthorisationResult) => {
                                switch (authorised) {
                                    case service.AuthorisationResult.NotFound:
                                        return Q(new model.HttpResponse(404, { "code": "ResourceNotFound", "message": "Resource Not Found" }));

                                    case service.AuthorisationResult.Failure:
                                        return Q(new model.HttpResponse(403, { "code": "Forbidden" }));

                                    case service.AuthorisationResult.Success:
                                        return controller[x](request);
                                }
                            });
開發者ID:MorleyDev,項目名稱:zander.server,代碼行數:12,代碼來源:server.ts

示例5:

		it(expectation, (done) => {
			Q(assertion(promiseDoneMistake)).done(() => {
				done();
			}, (err:Error) => {
				done(err);
			});
		});
開發者ID:AbraaoAlves,項目名稱:tsd,代碼行數:7,代碼來源:helper.ts

示例6: Q

 UploadSummaryCommand.prototype.runCommandAsync = function () {
     var _this = this;
     var filename = this.command.message;
     if (!filename) {
         return Q(null);
     }
     var deferred = Q.defer();
     fs.exists(filename, function (exists) {
         if (!exists) {
             deferred.resolve(null);
         }
         var projectId = _this.executionContext.variables[ctxm.WellKnownVariables.projectId];
         var type = "DistributedTask.Core.Summary";
         var name = "CustomMarkDownSummary-" + path.basename(filename);
         var hubName = _this.executionContext.jobInfo.description;
         var webapi = _this.executionContext.getWebApi();
         var taskClient = webapi.getQTaskApi();
         fs.stat(filename, function (err, stats) {
             if (err) {
                 deferred.reject(err);
             }
             else {
                 var headers = {};
                 headers["Content-Length"] = stats.size;
                 var stream = fs.createReadStream(filename);
                 taskClient.createAttachment(headers, stream, projectId, hubName, _this.executionContext.jobInfo.planId, _this.executionContext.jobInfo.timelineId, _this.executionContext.recordId, type, name).then(function () { return deferred.resolve(null); }, function (err) { return deferred.reject(err); });
             }
         });
     });
     return deferred.promise;
 };
開發者ID:ElleCox,項目名稱:vso-agent,代碼行數:31,代碼來源:task.uploadsummary.ts

示例7: authenticateGodUser

        public authenticateGodUser(authorization:any):Q.IPromise<AuthenticationResult> {
            if (!this._goduser)
                return Q(new AuthenticationResult(false, "Super-user not enabled on this server", undefined, undefined));

            if (!authorization || !authorization.scheme)
                return Q(new AuthenticationResult(false, "No or Incorrect Authentication details provided", undefined, undefined));
            if (authorization.scheme !== "Basic" || !authorization.basic)
                return Q(new AuthenticationResult(false, "Unrecognised authorization scheme", undefined, undefined));

            var username = authorization.basic.username;
            var password = authorization.basic.password;
            if (username && password && username === this._goduser.name && password === this._goduser.password)
                return Q(new AuthenticationResult(true, undefined, username, "00000000-0000-0000-0000-000000000000"));

            return Q(new AuthenticationResult(false, "No or Incorrect Authentication details provided", undefined, undefined));
        }
開發者ID:MorleyDev,項目名稱:zander.server,代碼行數:16,代碼來源:BasicAuthenticateUser.ts

示例8: validateProcessorsImpl

  return function validateProcessorsImpl() {
    const validationErrors = [];

    let validationPromise = Q();

    // Apply the validations on each processor
    dgeni.processors.forEach(function(processor) {
      validationPromise = validationPromise.then(function() {
        return validate.async(processor, processor.$validate).catch(function(errors) {
          validationErrors.push({
            processor: processor.name,
            package: processor.$package,
            errors: errors
          });
          log.error('Invalid property in "' + processor.name + '" (in "' + processor.$package + '" package)');
          log.error(errors);
        });
      });
    });

    validationPromise = validationPromise.then(function() {
      if ( validationErrors.length > 0 && dgeni.stopOnValidationError ) {
        return Q.reject(validationErrors);
      }
    });

    return validationPromise;
  };
開發者ID:angular,項目名稱:dgeni,代碼行數:28,代碼來源:processorValidation.ts

示例9: one

	it('async error', (done:(err) => void) => {
		Q().then(() => {
			return one()
		}).then(() => {
				done(new Error('test broken'));
			},
			done);
	});
開發者ID:Bartvds,項目名稱:mocha-unfunk-reporter,代碼行數:8,代碼來源:q.test.ts


注:本文中的Q.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。