當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript prelude.right函數代碼示例

本文整理匯總了TypeScript中@jonggrang/prelude.right函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript right函數的具體用法?TypeScript right怎麽用?TypeScript right使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了right函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: lookupIndices

 const lookupResult: T.Task<P.Either<string, LookupResult>> = T.co(function* () {
   const nonIndexResult: LookupResult  = yield settings.lookupFile(pieces);
   if (nonIndexResult.tag === LookupResultType.LRFILE) {
     return T.pure(P.right(nonIndexResult));
   }
   const eIndexResult: P.Either<string, LookupResult> = yield lookupIndices(
     settings.indices.map(ix => dropLastIfNull(pieces.concat(ix)))
   );
   if (P.isLeft(eIndexResult)) {
     return T.pure(P.left(eIndexResult.value));
   }
   const { value: indexResult } = eIndexResult;
   if (indexResult.tag === LookupResultType.LRNOTFOUND) {
     return T.pure(P.right(nonIndexResult));
   }
   if (indexResult.tag === LookupResultType.LRFILE && settings.redirectToIndex) {
     const file = indexResult.file;
     return T.pure(P.left((function () {
       const repieces = pieces.slice().reverse();
       if (repieces.length === 0) {
         return file.name;
       }
       const lastSegment = repieces[0];
       if (lastSegment == '') return file.name;
       return `${lastSegment}/${file.name}`;
     })()));
   }
   return T.pure(P.right(indexResult));
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:29,代碼來源:static.ts

示例2: go

 function go(e: P.Either<E, P.Either<A, B>>): P.Either<P.Either<E, P.Either<A, B>>, P.Either<E, B>> {
   if (P.isLeft(e)) {
     return P.right(e);
   }
   const ret = e.value;
   if (P.isLeft(ret)) {
     return P.left(f(ret.value));
   }
   return P.right(ret);
 }
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:10,代碼來源:parser.ts

示例3: it

    it('can render Cookie secure', () => {
      const cookieSecure = CO.createCookie('foo', 'baz', undefined, undefined, true, false, undefined);
      assert.deepEqual(
        CO.renderCookie(P.nothing, cookieSecure),
        P.right('foo=baz; Secure')
      );

      const cookieNonSecure = CO.createCookie('foo', 'baz', undefined, undefined, false, false, undefined);
      assert.deepEqual(
        CO.renderCookie(P.nothing, cookieNonSecure),
        P.right('foo=baz')
      );
    });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:13,代碼來源:cookie.ts

示例4: right

function runSync<A>(f: (...args: any[]) => A, args: any[], ctx: any): Either<Error, A> {
  try {
    let v = f.apply(ctx, args);
    return right(v);
  } catch (e) {
    return left(e);
  }
}
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:8,代碼來源:interpreter.ts

示例5: stepContinuePure

function stepContinuePure(fib: TaskFiber<any>) {
  if (fib._bhead === null) {
    fib._status = StateFiber.RETURN;
    fib._step = right((fib._step as Pure<any>)._1);
  } else {
    fib._status = StateFiber.STEP_BIND;
    fib._step = (fib._step as Pure<any>)._1;
  }
}
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:9,代碼來源:interpreter.ts

示例6: it

 it('compete should return the fastest task', function () {
   return shouldBe(
     right('right'),
     S.compete(
       T.delay(30).map(() => 'left'),
       T.delay(20).map(() => 'right')
     )
   );
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:9,代碼來源:async.ts

示例7: co

 return co(function* () {
   yield takeAVar(needsRunning);
   const a: A = yield maybe(set.task, identity, applyMaybe(modify, ma)) as Task<A>;
   yield writeRef(currRef, right(a));
   yield putAVar(responseVar, a);
   yield delay(set.delay);
   const responseVar_: AVar<A> = yield newEmptyAVar;
   yield writeRef(currRef, left(responseVar_));
   return loop(responseVar_, just(a));
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:10,代碼來源:auto-update.ts

示例8:

const weekDay: PS.Parser<Weekday> = PS.defParser(({ str, pos }) => {
  if ((str.length - pos) < 3)
    return P.left({ pos, error: new PS.ParseError('Expected one of day name') });

  for (let i = 0; i < 7; i++) {
    if (matchToken({ str, pos }, NUM_TO_WEEKDAY[i]) !== null) {
      return P.right({ result: i as Weekday, suffix: { str, pos: pos + 3 } });
    }
  }

  return P.left({ pos, error: new PS.ParseError('Expected one of day name') });
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:12,代碼來源:date.ts


注:本文中的@jonggrang/prelude.right函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。