本文整理汇总了TypeScript中ramda.omit函数的典型用法代码示例。如果您正苦于以下问题:TypeScript omit函数的具体用法?TypeScript omit怎么用?TypeScript omit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了omit函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: String
return event.reduce((result, e) => {
const key = String(e.id);
if (isCompletedEvent(e)) {
return omit([key], result);
}
return isInProgressEvent(e) ? { ...result, [key]: true } : result
}, inProgressEvents);
示例3: setURL
export const rescueLinode = (
linodeId: number,
devices: RescueRequestObject
): Promise<{}> =>
Request<{}>(
setURL(`${API_ROOT}/linode/instances/${linodeId}/rescue`),
setMethod('POST'),
setData({ devices: omit(['sdh'], devices) })
);
示例4: omit
export const removeMany = <E extends Entity>(list: string[], state: MappedEntityState<E>): MappedEntityState<E> => {
const itemsById = omit(list, state.itemsById);
return {
...state,
itemsById,
items: keys(itemsById),
}
};
示例5: mergeMap
mergeMap((action: any) => {
return http
.patch(
makeApiUrl(`/tk/task-board/${action.payload.id}`),
null,
R.omit(['id'], action.payload)
)
.then(Actions.UPDATE_TASK_BOARD.success)
.catch(Actions.UPDATE_TASK_BOARD.failure);
})
示例6: reduceRequestConfig
/** Generator */
export default <T>(...fns: Function[]): AxiosPromise<T> => {
const config = reduceRequestConfig(...fns);
if (config.validationErrors) {
return Promise.reject({
config: omit(['validationErrors'], config),
response: { data: { errors: config.validationErrors } }
});
}
return Axios(config);
/*
* If in the future, we want to hook into every single
* async action for the purpose of sending the request data
* to Google Tag Manager, we can uncomment out the following
* .then() and .catch() on return Axios(config)
*/
// .then(response => {
// /*
// * This is sending an event to the Google Tag Manager
// * data layer. This is important because it lets us track
// * async actions as custom events
// */
// if ((window as any).dataLayer) {
// (window as any).dataLayer = (window as any).dataLayer || [];
// (window as any).dataLayer.push({
// 'event': 'asyncActionSuccess',
// 'url': response.config.url,
// 'method': response.config.method,
// });
// };
// return response;
// })
// .catch(e => {
// /*
// * This is sending an event to the Google Tag Manager
// * data layer. This is important because it lets us track
// * async actions as custom events
// */
// if ((window as any).dataLayer) {
// (window as any).dataLayer = (window as any).dataLayer || [];
// (window as any).dataLayer.push({
// 'event': 'asyncActionFailure',
// 'url': e.response.config.url,
// 'method': e.response.config.method,
// });
// };
// return Promise.reject(e);
// });
};
示例7: dissoc
return R.assocPath(fieldsLevelArr, val, obj)
},
// dissoc/dissocPath
// String → {k: v} → {k: v}
dissoc(field, val, obj) {
return R.dissoc(field, val, obj)
},
// [Idx] → {k: v} → {k: v}
// Idx = String | Int
dissocPath(fieldsLevelArr, obj) {
return R.dissocPath(fieldsLevelArr, obj)
},
// omit :: [String] → {String: *} → {String: *}
omit(fieldsArr, obj) {
return R.omit(fieldsArr, obj)
},
// evolve :: {k: (v → v)} → {k: v} → {k: v}
evolve(fnOrKV, obj) {
return R.evolve(fnOrKV, obj)
},
// merge :: {k: v} → {k: v} → {k: v}
merge(objA, objB) {
return R.merge(objA, objB)
},
//// Logic ////
// defaultTo :: a → b → a | b
示例8: castModelName
export const enumDecorator = ({
modelName,
fields,
}: {
modelName: string;
fields: (Fields & WithHidden) | PositionsField | EnumField;
}): { modelName; fields: (Fields & WithHidden) | PositionsField | EnumField } => {
const TAG = '[enumDecorator]';
logger.log(TAG, { fields });
const enumFilterFields = R.filter(R.propEq('type', DynamicFormTypes.EnumFilter))(fields);
if (R.not(R.isEmpty(enumFilterFields))) {
const [, enumFilterField] = R.toPairs(enumFilterFields)[0];
logger.debug(TAG, { enumFilterField });
const enums = _.map(
_.keys(idx(enumFilterField as EnumField, _ => _.options.enumData)),
castModelName,
);
const current = castModelName(R.pathOr('', ['value'])(enumFilterField));
logger.debug(TAG, { enums, current });
// check if positions has value already
// save positions value if no value exists, update models' sequence for else
const positionsFieldPair = R.compose(
R.toPairs,
R.map(field => {
// raw is the original value, if exists, means it's update request
if (field.value && !field.raw) {
const value = R.is(String, field.value) ? JSON.parse(field.value) : field.value;
return { ...field, value, raw: field.value };
}
return { ...field, value: R.path([current, 'value'])(fields), raw: field.value };
}),
R.filter(R.pathEq(['options', 'type'], 'SortPosition')),
)(fields);
const filteredNames = R.without(current)(enums);
const filteredFields = R.omit(filteredNames)(fields);
const wrappedFields = current
? R.mergeDeepRight(filteredFields, {
[current]: {
isFilterField: true,
options: { filterType: R.path(['options', 'filterType'])(enumFilterField) },
value: R.isEmpty(positionsFieldPair)
? R.path([current, 'value'])(filteredFields)
: R.path([0, 1, 'value'])(positionsFieldPair),
},
...R.fromPairs(positionsFieldPair),
})
: filteredFields;
logger.debug(TAG, 'wrappedFields', {
current,
filteredNames,
filteredFields,
wrappedFields,
positionsFieldPair,
});
return { modelName, fields: wrappedFields };
}
return { modelName, fields };
};
示例9: omit
request: () =>
Promise.reject({
config: omit(['validationErrors'], config),
response: { data: { errors: config.validationErrors } }
})
示例10:
return state.update('currentBoard', board => {
if (!board) {
return null;
}
return board.merge(fromJS(R.omit(['id'], action.payload)));
});