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

TypeScript ramda.curryN函数代码示例

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

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



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

示例1: curryN

import { Observable, Subject, Observable as $ } from 'rx'
import { curryN, reduce, propIs } from 'ramda'
import { makeAPIRequest } from './api-request'
import { Token, DriverSources } from '../interfaces'
import {
  UpdatesState,
  Message,
  InlineQuery,
  ChosenInlineResult,
  CallbackQuery,
  TcombUpdate,
  TcombUpdatesState
} from '../runtime-types/types'

let max =
  curryN(3, (property: any, acc: any, current: any) =>
    current[property] > acc ? current[property] : acc)

let makeUpdatesResolver =
  curryN(2, (token: Token, offset: number) => makeAPIRequest({
    token,
    method: 'getUpdates',
    query: { offset, timeout: 60000 }
  }))

export function makeUpdates (initialState: TcombUpdatesState, token: Token): Observable<TcombUpdatesState> {
  UpdatesState(initialState)

  let resolve = makeUpdatesResolver(token)

  return $.return(initialState).expand(({offset}) => resolve(offset)
    .combineLatest(
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:32,代码来源:sources.ts


示例2: adapter

  return targetSA.isValidStream(stream)
    ? stream
    : targetSA.adapt(stream, sourceSA.streamSubscribe)
}

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
}

export let defaults = curryN(2, (transformations, obj) => compose<any, any, any, () => any>(
  evolve(transformations),
  pickAll)(
    chain(keys, [transformations, obj]),
    obj))
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:30,代码来源:index.ts


示例3: Request

  method: 'getWebhookInfo',
  options
})

export let getMe = (options = {}) => Request({
  type: 'sink',
  method: 'getMe',
  options
})

export let broadcast = curryN(2, (options = {}, update: Update) => Request({
  type: 'sink',
  method: 'sendMessage',
  options: defaults(
    {
      chat_id: defaultTo(path(['message', 'chat', 'id'], update)),
      text: defaultTo('Null-catch: no text provided'),
      reply_markup: JSON.stringify
    },
    options)
}))

export let reply = curryN(2, (options = {}, update: Update) => Request({
  type: 'sink',
  method: 'sendMessage',
  options: defaults(
    {
      chat_id: defaultTo(path(['message', 'chat', 'id'], update)),
      reply_to_message_id: defaultTo(path(['message', 'message_id'], update)),
      text: defaultTo('Null-catch: no text provided'),
      reply_markup: JSON.stringify
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:31,代码来源:sinks.ts


示例4: curryN

 *
 * This function is curried.
 *
 * @sig Number a -> a -> a -> b
 * @param {Number} the minimum number
 * @param {Number} the maximum number
 * @param {Number} the value to test
 * @return {Boolean} is the value in the range?
 * @example
 * isWithin(1, 5, 3) //=> true
 * isWithin(1, 5, 1) //=> true
 * isWithin(1, 5, 5) //=> true
 * isWithin(1, 5, 5.1) //=> false
 */
const isWithin = curryN(3, (min, max, value) => {
  const isNumber = is(Number)
  return isNumber(min) && isNumber(max) && isNumber(value) && gte(value, min) && gte(max, value)
})

// a workaround to deal with __ not being available from the ramda types in typescript
const containsText = curryN(2, (textToSearch, list) => contains(list, textToSearch))

/**
 * Are we dealing with a promise?
 */
const isPromise = obj =>
  !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'

// the default headers given to axios
export const DEFAULT_HEADERS = {
  Accept: 'application/json',
  'Content-Type': 'application/json',
开发者ID:skellock,项目名称:apisauce,代码行数:32,代码来源:apisauce.ts


示例5: useWith

import {
  curryN, pipe, path,
  useWith, any, propEq,
  defaultTo, find
} from 'ramda'

export let entityIs = useWith(
  any, [
    propEq('type'),
    pipe(
      path(['message', 'entities']),
      defaultTo([]))
  ])

export let getEntityFirst = useWith(
  find, [
    propEq('type'),
    pipe(
      path(['message', 'entities']),
      defaultTo([]))
  ])

export let getEntityFirstValue = curryN(2, (type, update) => {
  let match = getEntityFirst(type, update)
  return update.message.text.substr(match.offset, match.length)
})
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:26,代码来源:entities.ts


示例6: curryN

    return hotName
}

/**
 * Unload the module from the browser and delete from registry
 * @param moduleName
 */
export const unload = curryN(1, (context: Context, moduleName: string) => {
    const { logger, System } = context

    logger(`unloading ${moduleName}`)

    if (System.has(moduleName)) {
        const module = System.get(moduleName)

        var unloadFunc = module.__unload || (module.default ? module.default.__unload : undefined);
        if (typeof unloadFunc == 'function')
        unloadFunc();
    }

    System.delete(moduleName)
})


export type ReloadOptions = {
    entries: string[],
    preload: string[]
}

/**
开发者ID:alexisvincent,项目名称:systemjs-hmr,代码行数:30,代码来源:util.ts


示例7: return

        obs.onError(err)
      } else {
        obs.onNext(res)
      }
      obs.onCompleted()
    })

  return () => request.abort()
})

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)
))

export function makeAPIRequest (
  {
    token,
    method,
    query,
    httpMethod = 'POST'
  }: TelegramAPIRequest,
  multipart = false
): Observable<TelegramAPIResponseResult | TelegramAPIError> {
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:31,代码来源:api-request.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.defaultTo函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.curry函数代码示例发布时间: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