• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.ifElse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ramda.ifElse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ifElse函数的具体用法?TypeScript ifElse怎么用?TypeScript ifElse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ifElse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: compose

getIdOrNullFor = type => compose(
  ifElse(isNil, always(null), compose(
    ifElse(
      contains(type),
      compose<string, string[], string, number, Record<string, number>>(
        objOf(`${type}_id`), Number, last, split('-'),
      ),
      always(null),
    ),
  )),
);
开发者ID:displague,项目名称:manager,代码行数:11,代码来源:createDevicesFromStrings.ts


示例2: adapter

export function adapter (runSA: StreamAdapter) {
  let adapt: (streamOrFunc: Observable<any> | StreamFunction) => any = ifElse(
    isObservable,
    adaptStream,
    ifElse(
      is(Function),
      adaptFunction,
      identity))

  function adaptStream (stream: Observable<any>) {
    return convertStream(stream, RxAdapter, runSA)
  }

  function adaptFunction (func: StreamFunction) {
    return (...args: any[]) => adaptStream(func(...args))
  }

  return adapt
}
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:19,代码来源:index.ts


示例3: curryN

let transformReq = curryN(2, (req: Request, multipart: boolean) => ifElse(
  () => multipart,
  pipe<any, any, any, any>(
    mapObjIndexed((v: any, k: string) => v
      ? req[propOr(false, 'path', v) ? 'attach' : 'field'](k, v)
      : req),
    values,
    last
  ),
  req.send.bind(req)
))
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:11,代码来源:api-request.ts


示例4: compose

import { NoContent } from './no-content';

import { DataResolver } from './app.resolver';

import { routes as blogRoutes, asyncRoutes as blogAsyncRoutes } from './blog/blog.routing';

import { prop, compose, split, find, trim, equals, nth, ifElse, identity } from 'ramda';

export const appNavLinks: NavigationConfig = [
  ...Pages.navLinks,
  ...Layouts.navLinks,
  ...Authentication.navLinks,
];

const layout = compose(
    ifElse(identity, compose(nth(1), split('=')), identity),
    find(compose(equals('layout'), trim, nth(0), split('='))),
    split(';')
  )(document.cookie);

const layouts = {
  'horizontal': HorizontalLayout,
  'vertical' : VerticalLayout
};

export const routes: RouterConfig = [
  {
    path: '',
    component: layouts[layout],
    children: [
      ...Pages.routes,
开发者ID:the-fool,项目名称:attacus-atlas,代码行数:31,代码来源:app.routes.ts


示例5: isWithin

export const NONE = null
export const CLIENT_ERROR = 'CLIENT_ERROR'
export const SERVER_ERROR = 'SERVER_ERROR'
export const TIMEOUT_ERROR = 'TIMEOUT_ERROR'
export const CONNECTION_ERROR = 'CONNECTION_ERROR'
export const NETWORK_ERROR = 'NETWORK_ERROR'
export const UNKNOWN_ERROR = 'UNKNOWN_ERROR'
export const CANCEL_ERROR = 'CANCEL_ERROR'

const TIMEOUT_ERROR_CODES = ['ECONNABORTED']
const NODEJS_CONNECTION_ERROR_CODES = ['ENOTFOUND', 'ECONNREFUSED', 'ECONNRESET']
const in200s = isWithin(200, 299)
const in400s = isWithin(400, 499)
const in500s = isWithin(500, 599)
const statusNil = ifElse(isNil, always(undefined), prop('status'))

/**
 * What's the problem for this axios response?
 */
export const getProblemFromError = error => {
  // first check if the error message is Network Error (set by axios at 0.12) on platforms other than NodeJS.
  if (error.message === 'Network Error') return NETWORK_ERROR
  if (axios.isCancel(error)) return CANCEL_ERROR

  // then check the specific error code
  return cond([
    // if we don't have an error code, we have a response status
    [isNil, () => getProblemFromStatus(statusNil(error.response))],
    [containsText(TIMEOUT_ERROR_CODES), always(TIMEOUT_ERROR)],
    [containsText(NODEJS_CONNECTION_ERROR_CODES), always(CONNECTION_ERROR)],
开发者ID:skellock,项目名称:apisauce,代码行数:30,代码来源:apisauce.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.inc函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.head函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap