• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.pluck函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ramda.pluck函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pluck函数的具体用法?TypeScript pluck怎么用?TypeScript pluck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pluck函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: async

 async (data: IOMessage[]) => {
   const to = data[0].to // Should be consistent across batches
   const indexedData = toPairs(data) as Array<[string, IOMessage]>
   const sortedIndexedData = sortByContent(indexedData)
   const originalIndexes = pluck(0, sortedIndexedData) as string[]
   const sortedData = pluck(1, sortedIndexedData) as IOMessage[]
   const strLength = map(obj => JSON.stringify(obj).length, sortedData)
   const batches = batchData(strLength, sortedData)
   const promises = map((batch: IOMessage[]) => !!to ? messagesAPI.translate(to, batch) : Promise.resolve(pluck('content', batch)), batches)
   const translations = await Promise.all(promises).then(res => flatten<string>(res))
   const indexedTranslations = zip(originalIndexes, translations) as Array<[string, string]>
   const translationsInOriginalOrder = sortByOriginalIndex(indexedTranslations)
   return pluck(1, translationsInOriginalOrder)
 }
开发者ID:vtex,项目名称:apps-client-node,代码行数:14,代码来源:messagesLoader.ts


示例2:

 R.filter(role => {
   // 判断返回的是否是 ids
   if (user.roles && _.isObjectLike(user.roles[0])) {
     return R.contains(role.id)(R.values(R.pluck('id', user.roles)));
   }
   return R.contains(role.id)(user.roles);
 }),
开发者ID:danielwii,项目名称:asuna-admin,代码行数:7,代码来源:menu.redux.ts


示例3: getNextNumber

  /**
   * Return the next running number in an array of records
   * @param {string} prop The property name
   * @param data The array of records containing the property
   */
  static getNextNumber(prop: string, data: Array<any>) {
    if (R.isEmpty(data)) { return 1 }
    const getNextNumber = R.pipe(
      R.sortBy(R.prop(prop)),
      R.pluck(prop),
      R.last()
    );

    return parseInt(getNextNumber(data)) + 1;
  }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:15,代码来源:array-helper.ts


示例4: getUrls

function* getUrls(ids: Array<string>): SagaIterator {
  try {
    const bookmarkInfos: Array<BookmarkInfo> = yield all(ids.map((id) => call(getBookmarkInfo, id)))

    const filteredBookmarkInfos = bookmarkInfos.filter(
      R.both(R.propEq('isSimulated', false), R.propEq('type', BOOKMARK_TYPES.BOOKMARK))
    )
    return R.pluck('url', filteredBookmarkInfos)
  } catch (err) {
    console.error(err)

    return []
  }
}
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:14,代码来源:openBookmarksInBrowser.ts


示例5: adjust

  // adjust :: (a → a) → Number → [a] → [a]
  adjust(index, fn, list) {
    return R.adjust(fn, index, list)
  },
  // remove :: Number → Number → [a] → [a] (drop / dropLast)
  remove(fromIndex, number, list) {
    return R.remove(fromIndex, number, list)
  },
  // without {a∣a∉xs ∩ a∈ys} :: [a] → [a] → [a]
  without(listA, listB) {
    return R.without(listA, listB)
  },

  // sum :: [Number] → Number
  sum(filed, list) {
    return R.compose(R.sum, R.pluck(filed))(list)
  },
  // pluck :: Functor f => k → f {k: v} → f v
  pluck(filed, list) {
    return R.pluck(filed)(list)
  },
  // filter :: Filterable f => (a → Boolean) → f a → f a
  filter(fn, list) {
    return R.filter(fn, list)
  },
  // findIndex :: (a → Boolean) → [a] → Number
  findIndex(field, val, list) {
    return R.findIndex(R.propEq(field, val))(list)
  },
  // concat :: [a] → [a] → [a]
  concat(listA, listB) {
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts


示例6: getPolygonFromPoints

      y
    })
  },
  getPolygonFromPoints (points: TwoDimensionalPoint[]): Line {
    const pointsSorted = R.sortWith([
      R.ascend(R.prop('x')),
      R.ascend(R.prop('y'))
    ])(points) as TwoDimensionalPoint[]

    const minPoint = pointsSorted[0]
    const maxPoint = R.last(pointsSorted)

    const pointsBellow = [minPoint].concat(pointsSorted.filter(point => {
      return isPointBellow(point, minPoint) && isPointBellow(point, maxPoint) && !R.equals(point, maxPoint)
    }))
    const pointsBellowPath = flatten ( zip( R.pluck('x', pointsBellow), R.pluck('y', pointsBellow) ) ) as number[]

    const pointsAbove = R.sortWith([
        R.descend(R.prop('x')),
        R.descend(R.prop('y'))
      ]
    )(R.difference(pointsSorted, pointsBellow))
    const pointsAbovePath = flatten ( zip( R.pluck('x', pointsAbove), R.pluck('y', pointsAbove) ) ) as number[]

    return new Line({
      points: pointsBellowPath.concat(pointsAbovePath),
      closed: true,
      stroke: '#fff',
      strokeWidth: 2,
      tension: 0.2
    })
开发者ID:neonerd,项目名称:weallmeetatthoseplaces,代码行数:31,代码来源:FaceGenerator.ts


示例7:

		.map(res => R.pipe(R.pluck('$user'), R.pluck('email'))(res))
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:user.model.ts


示例8: rPluck

const pluck = <K extends string, T> (p: K) => (list: ReadonlyArray<T>) => rPluck(p, list)
开发者ID:vtex,项目名称:apps-client-node,代码行数:1,代码来源:cacheControl.ts


示例9: pluck

import { LogLevel } from '../../../clients/Logger'
import { GraphQLServiceContext } from '../typings'
import { toArray } from '../utils/array'
import { generatePathName } from '../utils/pathname'

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.prop函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.pipe函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap