本文整理汇总了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 };
};
示例2: has
const isReactNativeEvent = (value: any) =>
typeof value !== 'undefined' && value !== null && has("nativeEvent", value) && has("target", value) && has("type", value)
示例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
示例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
}
示例5: has
const isReactNativeEvent = (value: any) =>
value !== null && has("nativeEvent", value) && has("target", value) && has("type", value)