本文整理汇总了TypeScript中@jonggrang/task.makeTask函数的典型用法代码示例。如果您正苦于以下问题:TypeScript makeTask函数的具体用法?TypeScript makeTask怎么用?TypeScript makeTask使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeTask函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: request
return T.toPromise(withApp(app, handler =>
T.makeTask(cb => {
request(handler)
.get('/')
.expect(200)
.expect('hello', cb);
return T.nonCanceler;
})
示例2: waitSignal
function waitSignal(signal: string): T.Task<void> {
return T.makeTask(cb => {
process.once(signal as any, cb as any);
return T.thunkCanceller(() => {
process.removeListener(signal, cb as any);
});
});
}
示例3:
export function writeSock<W extends Writable>(writable: W, buffer: Buffer): T.Task<void> {
return T.makeTask({
writable,
buffer,
handle: handleWriteSock,
cancel: doNothingTask
} as T.Computation<void>);
}
示例4: cleanUpListenerWS
export function pipeStream<W extends Writable, R extends Readable>(ws: W, rs: R, opts?: { end?: boolean }): T.Task<void> {
return T.makeTask(cb => {
rs.pipe(ws, opts);
const doEnd = (!opts || opts.end !== false) && (ws as any) !== process.stdout && (ws as any) !== process.stderr;
const state: PipeState = {
onError: null,
onSuccess: null,
resolved: false
};
if (doEnd) {
state.onError = onErrorWS.bind(null, state, ws, cb);
state.onSuccess = onSuccessWS.bind(null, state, ws, cb);
ws.once('error', state.onError as any);
ws.once('finish', state.onSuccess as any);
return T.thunkCanceller(() => cleanUpListenerWS(state, ws));
}
// we not use automatic finish, so attach to readable
state.onError = onErrorRS.bind(null, state, rs, cb);
state.onSuccess = onSuccessRS.bind(null, state, rs, cb);
rs.once('error', state.onError as any);
rs.once('end', state.onSuccess as any);
return T.thunkCanceller(() => cleanUpListenerRS(state, rs));
});
}
示例5: makeTask
export function readAVar<A>(avar: AVar<A>): Task<A> {
return makeTask(new AVarRead(avar));
}