本文整理汇总了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" }));
}
}
示例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 });
}
};
示例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));
});
示例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);
}
});
示例5:
it(expectation, (done) => {
Q(assertion(promiseDoneMistake)).done(() => {
done();
}, (err:Error) => {
done(err);
});
});
示例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;
};
示例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));
}
示例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;
};
示例9: one
it('async error', (done:(err) => void) => {
Q().then(() => {
return one()
}).then(() => {
done(new Error('test broken'));
},
done);
});