當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ramda.has函數代碼示例

本文整理匯總了TypeScript中ramda.has函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript has函數的具體用法?TypeScript has怎麽用?TypeScript has使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了has函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: castModelKey

export const hiddenComponentDecorator = ({
  modelName,
  fields,
}: {
  modelName: string;
  fields: Fields;
}): { modelName; fields: Fields & WithHidden } => {
  const TAG = '[hiddenComponentDecorator]';
  logger.log(TAG, { fields });

  let wrappedFields = R.omit([castModelKey('createdAt'), castModelKey('updatedAt')])(fields);
  if (R.has('id', wrappedFields)) {
    const hidden = R.isNil(wrappedFields.id.value);
    wrappedFields = R.mergeDeepRight(wrappedFields, { id: { options: { hidden } } });
  }

  const positions = R.filter(R.pathEq(['options', 'type'], 'SortPosition'))(wrappedFields);
  if (!R.isEmpty(positions)) {
    const hiddenPositions = R.map(position => ({
      ...position,
      options: { hidden: true },
    }))(positions);

    wrappedFields = R.mergeDeepRight(wrappedFields, { ...hiddenPositions });
  }
  logger.log(TAG, 'wrappedFields', { wrappedFields }, diff(fields, wrappedFields));
  return { modelName, fields: wrappedFields };
};
開發者ID:danielwii,項目名稱:asuna-admin,代碼行數:28,代碼來源:index.ts

示例2: has

const isReactNativeEvent = (value: any) =>
  typeof value !== 'undefined' && value !== null && has("nativeEvent", value) && has("target", value) && has("type", value)
開發者ID:nick121212,項目名稱:reactotron,代碼行數:2,代碼來源:reactotron-mst.ts

示例3: getArrObjFieldByFieldValue

  getArrObjFieldByFieldValue(getField, findField, findFieldValue, list) {
    return R.prop(getField, this.getArrObjByFieldValue(findField, findFieldValue, list))
  },
  //flattenObjArr :: 
  flattenObjArr(filedA, filedB, list) {
    return R.compose(R.pluck(filedB), R.flatten, R.pluck(filedA))(list)
  },
  flattenObjArrSum(filedA, filedB, list) {
    return R.compose(R.sum, R.pluck(filedB), R.flatten, R.pluck(filedA))(list)
  },

  //// {} ////

  // has :: s → {s: x} → Boolean
  has(field, obj) {
    return R.has(field)(obj)
  },
  // keys :: {k: v} → [k]
  keys(obj) {
    return R.keys(obj)
  },
  // values :: {k: v} → [v]
  values(obj) {
    return R.values(obj)
  },

  // prop :: s → {s: a} → a | Undefined
  prop(obj) {
    return R.prop(obj)
  },
  // propOr :: a → String → Object → a
開發者ID:stefaniepei,項目名稱:react-redux-scaffold,代碼行數:31,代碼來源:ramda.ts

示例4: pluck

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)
  }
  return null
}
開發者ID:vtex,項目名稱:apps-client-node,代碼行數:31,代碼來源:error.ts

示例5: has

const isReactNativeEvent = (value: any) =>
  value !== null && has("nativeEvent", value) && has("target", value) && has("type", value)
開發者ID:chenrui2014,項目名稱:reactotron,代碼行數:2,代碼來源:reactotron-mst.ts


注:本文中的ramda.has函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。