• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.omit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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 };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:28,代码来源:index.ts


示例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);
开发者ID:displague,项目名称:manager,代码行数:9,代码来源:event.helpers.ts


示例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) })
  );
开发者ID:linode,项目名称:manager,代码行数:9,代码来源:linodeActions.ts


示例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),
  }
};
开发者ID:displague,项目名称:manager,代码行数:9,代码来源:store.helpers.ts


示例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);
 })
开发者ID:A-Horse,项目名称:bblist,代码行数:10,代码来源:task.epic.ts


示例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);
  // });
};
开发者ID:linode,项目名称:manager,代码行数:52,代码来源:index.ts


示例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
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts


示例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 };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:65,代码来源:index.ts


示例9: omit

 request: () =>
   Promise.reject({
     config: omit(['validationErrors'], config),
     response: { data: { errors: config.validationErrors } }
   })
开发者ID:linode,项目名称:manager,代码行数:5,代码来源:index.ts


示例10:

 return state.update('currentBoard', board => {
   if (!board) {
     return null;
   }
   return board.merge(fromJS(R.omit(['id'], action.payload)));
 });
开发者ID:A-Horse,项目名称:bblist,代码行数:6,代码来源:task.reducer.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.partial函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.nth函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap