当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.chain函数代码示例

本文整理汇总了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);
 }
开发者ID:devkat,项目名称:calendar,代码行数:8,代码来源:dom.ts

示例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];
}
开发者ID:tycho01,项目名称:html2jade,代码行数:12,代码来源:html2jade.ts

示例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;
    }
开发者ID:sprengerjo,项目名称:katas_js,代码行数:17,代码来源:gol.ts

示例4: curryN

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

示例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>) {
开发者ID:vtex,项目名称:apps-client-node,代码行数:31,代码来源:error.ts


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