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


TypeScript ramda.uniqBy函数代码示例

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


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

示例1:

const extractItemsBy = primaryKey =>
  R.compose(
    R.uniqBy(R.prop(primaryKey)),
    R.flatten,
    R.map(R.path(['data', 'items'])),
    R.flatten,
  );
开发者ID:danielwii,项目名称:asuna-admin,代码行数:7,代码来源:async.ts

示例2: list

export function list(address: string, limit = 100): Promise<Array<T_TX>> {
    return request({ url: `${configGet('node')}/transactions/address/${address}/limit/${limit}` })
        .then(pipe(
            prop('0'),
            uniqBy(prop('id')) as any,
        ))
        .then(transactions => parseTx(transactions as any, false));
}
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:8,代码来源:transactions.ts

示例3: detectBrowsers

/** returns list of detected browsers */
function detectBrowsers(): Bluebird<Browser[]> {
  // we can detect same browser under different aliases
  // tell them apart by the full version property
  const removeDuplicates = uniqBy(prop('version'))
  return Bluebird.mapSeries(browsers, checkOneBrowser)
    .then(_.compact)
    .then(removeDuplicates) as Bluebird<Browser[]>
}
开发者ID:lgandecki,项目名称:cypress,代码行数:9,代码来源:detect.ts

示例4: uniqBy

export const detect = (goalBrowsers?: Browser[]): Bluebird<FoundBrowser[]> => {
  // we can detect same browser under different aliases
  // tell them apart by the name and the version property
  if (!goalBrowsers) {
    goalBrowsers = browsers
  }

  const removeDuplicates = uniqBy((browser: FoundBrowser) =>
    props(['name', 'version'], browser)
  )
  const compactFalse = (browsers: any[]) => compact(browsers) as FoundBrowser[]

  return Bluebird.mapSeries(goalBrowsers, checkBrowser)
    .then(flatten)
    .then(compactFalse)
    .then(removeDuplicates)
}
开发者ID:YOU54F,项目名称:cypress,代码行数:17,代码来源:detect.ts

示例5: listUTX

export function listUTX(address?: string): Promise<Array<T_TX>> {
    return request<Array<T_API_TX>>({ url: `${configGet('node')}/transactions/unconfirmed` })
        .then(uniqBy(prop('id')))
        .then(transactions => filterByAddress(transactions, address))
        .then(transactions => parseTx(transactions, true));
}
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:6,代码来源:transactions.ts

示例6: error

export async function error (ctx: GraphQLServiceContext, next: () => Promise<void>) {
  const {
    vtex: {
      account,
      workspace,
      route: {
        id,
      },
    },
  } = ctx

  let graphQLErrors: any[] | null = null

  try {
    await next()

    graphQLErrors = parseErrorResponse(ctx.graphql.graphqlResponse || {})
  }
  catch (e) {
    const formatError = ctx.graphql.formatters!.formatError

    if (e.isGraphQLError) {
      const response = JSON.parse(e.message)
      graphQLErrors = parseError(response)
      ctx.body = response
    } else {
      graphQLErrors = [formatError(e)]
      ctx.body = {errors: graphQLErrors}
    }

    // Add response
    ctx.status = e.statusCode || 500
    if (e.headers) {
      ctx.set(e.headers)
    }
  }
  finally {
    if (graphQLErrors) {
      const uniqueErrors = uniqBy((e) => {
        if (e.originalError && e.originalError.request) {
          return e.originalError.request.path
        }
        return e
      }, graphQLErrors)
      console.error(`[node-vtex-api graphql errors] total=${graphQLErrors.length} unique=${uniqueErrors.length}`, uniqueErrors)
      ctx.graphql.status = 'error'

      // Do not generate etag for errors
      ctx.remove(META_HEADER)
      ctx.remove(ETAG_HEADER)

      // In production errors, add two second cache
      if (production) {
        ctx.set(CACHE_CONTROL_HEADER, `public, max-age=${TWO_SECONDS_S}`)
      } else {
        ctx.set(CACHE_CONTROL_HEADER, `no-cache, no-store`)
      }

      // Log each error to splunk individually
      forEach((err: any) => {
        // Add pathName to each error
        if (err.path) {
          err.pathName = generatePathName(err.path)
        }

        const log = {
          ...err,
          routeId: id,
        }

        // Grab level from originalError, default to "error" level.
        let level = err.originalError && err.originalError.level as LogLevel
        if (!level || !(level === LogLevel.Error || level === LogLevel.Warn)) {
          level = LogLevel.Error
        }

        ctx.clients.logger.sendLog('-', log, level).catch((reason) => {
          console.error('Error logging error 🙄 retrying once...', reason ? reason.response : '')
          ctx.clients.logger.sendLog('-', log, level).catch()
        })
      }, uniqueErrors)

      // Expose graphQLErrors with pathNames to timings middleware
      ctx.graphql.graphQLErrors = uniqueErrors

      // Show message in development environment
      if (!production) {
        console.log(getSplunkQuery(account, workspace))
      }
    } else {
      ctx.graphql.status = 'success'
    }
  }
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:94,代码来源:error.ts


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