本文整理汇总了TypeScript中@jonggrang/task.runTask函数的典型用法代码示例。如果您正苦于以下问题:TypeScript runTask函数的具体用法?TypeScript runTask怎么用?TypeScript runTask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runTask函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: done
pendingWrites.onceZero(() => {
T.runTask(T.forInPar_(uploadedFiles, file => storage.removeFile(file)), (err) => {
/* istanbul ignore if */
if (err) return done(err);
done(uploadError);
});
});
示例2: removePlaceholder
T.runTask(fileFilter(ctx, file), (err, includeFile) => {
if (err) {
removePlaceholder(files, placeholder);
return abortWithError(err);
}
if (!includeFile) {
removePlaceholder(files, placeholder);
return filestream.resume();
}
let aborting = false;
pendingWrites.increment();
filestream.on('error', (err) => {
pendingWrites.decrement();
abortWithError(err);
});
filestream.on('limit', function () {
aborting = true;
abortWithCode('LIMIT_FILE_SIZE', fieldname);
});
T.runTask(storage.handleFile(file, filestream as any), (err, finfo) => {
// sometimes the limit event was fired before we attach the listener
// so, check the truncated property here
if ((filestream as any).truncated && !aborting) filestream.emit('limit');
if (aborting) {
removePlaceholder(files, placeholder);
uploadedFiles.push(assign(file, finfo || {}) as any);
return pendingWrites.decrement();
}
if (err) {
removePlaceholder(files, placeholder);
pendingWrites.decrement();
return abortWithError(err);
}
replacePlaceholder(files, placeholder, finfo as any);
uploadedFiles.push(finfo as any);
pendingWrites.decrement();
indicateDone();
});
});
示例3: mutter
(form as any).getLength((err: Error | null, len: number) => {
if (err) return cb(err);
const app = mutter(simpleApp);
const request = new PassThrough();
(request as any).complete = false;
form.once('end', () => {
(request as any).complete = true;
});
form.pipe(request);
(request as any).headers = {
'content-type': 'multipart/form-data; boundary=' + (form as any).getBoundary(),
'content-length': len
};
const ctx: W.HttpContext = W.createHttpContext(request as any);
T.runTask(app(ctx, T.pure), err => {
if (err) return cb(err);
cb(null, ctx);
});
});
示例4: insertPlaceholder
busboy.on('file', (fieldname, filestream, originalname, encoding, mimeType) => {
if (!fieldname) return filestream.resume();
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
if (limits && limits.hasOwnProperty('fieldNameSize')) {
if (fieldname.length > (limits as any).fieldNameSize) return abortWithCode('LIMIT_FIELD_KEY');
}
const file: FileUpload = {
fieldname,
originalname,
encoding,
mimeType
};
const placeholder = insertPlaceholder(files, file);
T.runTask(fileFilter(ctx, file), (err, includeFile) => {
if (err) {
removePlaceholder(files, placeholder);
return abortWithError(err);
}
if (!includeFile) {
removePlaceholder(files, placeholder);
return filestream.resume();
}
let aborting = false;
pendingWrites.increment();
filestream.on('error', (err) => {
pendingWrites.decrement();
abortWithError(err);
});
filestream.on('limit', function () {
aborting = true;
abortWithCode('LIMIT_FILE_SIZE', fieldname);
});
T.runTask(storage.handleFile(file, filestream as any), (err, finfo) => {
// sometimes the limit event was fired before we attach the listener
// so, check the truncated property here
if ((filestream as any).truncated && !aborting) filestream.emit('limit');
if (aborting) {
removePlaceholder(files, placeholder);
uploadedFiles.push(assign(file, finfo || {}) as any);
return pendingWrites.decrement();
}
if (err) {
removePlaceholder(files, placeholder);
pendingWrites.decrement();
return abortWithError(err);
}
replacePlaceholder(files, placeholder, finfo as any);
uploadedFiles.push(finfo as any);
pendingWrites.decrement();
indicateDone();
});
});
});
示例5: it
it(desc, done => {
T.runTask(testRunner(headers, fp, rsp), done);
});