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