當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。