本文整理匯總了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>) {