本文整理汇总了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(
示例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))
示例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
示例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',
示例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)
})
示例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[]
}
/**
示例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> {