当前位置: 首页>>代码示例>>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;未经允许,请勿转载。