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


TypeScript ramda.curryN函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。