本文整理汇总了TypeScript中ramda.chain函数的典型用法代码示例。如果您正苦于以下问题:TypeScript chain函数的具体用法?TypeScript chain怎么用?TypeScript chain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chain函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: siblings
public siblings(selector?: string): Dom {
const children: Element[] = R.chain((e: Element) => Array.from(e.parentElement.children))(this.elements);
const siblings: Element[] = (R as any).without(this.elements)(children); // todo: R as any -> ramda.d.ts update
const filtered: Element[] = selector
? R.filter((e: Element) => e.matches(selector))(siblings)
: siblings;
return new Dom(filtered);
}
示例2: element
function element(el: HTMLElement): string[] {
let name = el.localName;
let attrs = el.attributes;
let attrR = Array.from(attrs);
let attrRest = attrR.filter(a => !['id','class'].includes(a.name));
let id = el.id ? '#' + el.id : '';
let classes = attrs.getNamedItem('class').value.split(' ').map(s => '.' + s).join('');
let tag = name + id + classes;
var box = attrRest.length ? [tag + '('].concat(attrRest.map(attribute).map(pad), [')']) : [tag];
let content: string[] = R.chain(node)(children(el)).map(pad);
return [...box, ...content];
}
示例3: nextGeneration
static nextGeneration(cells: [number[]]) {
const destructIdentity = (value: string) => R.map(Number.parseInt, R.split(',', value));
const fn = (key: any, value: any) => {
return GameOfLife.isAlive(value, R.contains(destructIdentity(key), cells));
};
const nextGen = R.compose(
R.map(destructIdentity),
R.keys,
cs => GameOfLife.filterWithKeys(fn, cs),
R.countBy((cell: Number) => R.identity(cell.toString())),
R.chain(GameOfLife.getNeighbours)
)(cells);
return nextGen;
}
示例4: curryN
export let defaults = curryN(2, (transformations, obj) => compose<any, any, any, () => any>(
evolve(transformations),
pickAll)(
chain(keys, [transformations, obj]),
obj))
示例5: pluck
const CACHE_CONTROL_HEADER = 'cache-control'
const META_HEADER = 'x-vtex-meta'
const ETAG_HEADER = 'etag'
const TWO_SECONDS_S = 2
const sender = process.env.VTEX_APP_ID
const getSplunkQuery = (account: string, workspace: string) =>
`Try this query at Splunk to retrieve error log: 'index=colossus key=log_error sender="${sender}" account=${account} workspace=${workspace}'`
const parseMessage = pluck('message')
const arrayHasError = any(has('errors'))
const filterErrors = filter(has('errors')) as (x: ReadonlyArray<{}>) => ReadonlyArray<{}>
const chainErrors = chain(prop<any, any>('errors'))
const hasError = compose(arrayHasError, toArray)
const parseError = compose(chainErrors, filterErrors, toArray)
const parseErrorResponse = (response: any) => {
if (hasError(response)) {
return parseError(response)
}
return null
}
const production = process.env.VTEX_PRODUCTION === 'true'
export async function error (ctx: GraphQLServiceContext, next: () => Promise<void>) {