當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。