当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript task.makeTask函数代码示例

本文整理汇总了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;
   })
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:respond.test.ts

示例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);
    });
  });
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:run.ts

示例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>);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:utils.ts

示例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));
  });
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:24,代码来源:pipe.ts

示例5: makeTask

export function readAVar<A>(avar: AVar<A>): Task<A> {
  return makeTask(new AVarRead(avar));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:3,代码来源:index.ts


注:本文中的@jonggrang/task.makeTask函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。