当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.pathEq函数代码示例

本文整理汇总了TypeScript中ramda.pathEq函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pathEq函数的具体用法?TypeScript pathEq怎么用?TypeScript pathEq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pathEq函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: findChildImages

export function findChildImages(parentName: string, imagesConfigMap: ImagesConfigMap): string[] {
  const confPairs = toPairs(imagesConfigMap) as [string, ImageConfig][];
  return pipe(
    filter<[string, ImageConfig]>(pathEq(['1', 'baseimage'], parentName)),
    map((arr: [string, ImageConfig]) => arr[0])
  )(confPairs);
}
开发者ID:d6u,项目名称:docker-build-layers,代码行数:7,代码来源:Util.ts

示例3: toPath

export const match = (modifier: string, props: MatchProps = {}) => {
  if (modifier === SELF_MODIFIER_NAME) {
    return true
  }

  const modifierPath = toPath(modifier)

  const linearMatch = target => {
    const value = path(modifierPath, target)

    if (is(Boolean, value)) {
      return value
    }

    if (isNil(value)) {
      return false
    }

    return !isEmpty(value)
  }

  const matcher =
    modifierPath.length > 1
      ? pathEq(init(modifierPath), last(modifierPath))
      : linearMatch

  return matcher(props)
}
开发者ID:monstrs,项目名称:elementum,代码行数:28,代码来源:match.ts

示例4:

    [getType(bookmarkCreators.removeBookmarkTree)]: (
      state: BookmarkState,
      {payload}: ReturnType<typeof bookmarkCreators.removeBookmarkTree>
    ) => {
      const removeFromIndex = state.trees.findIndex(R.pathEq(['parent', 'id'], payload.id))
      if (removeFromIndex < 0) return state

      return {
        ...state,
        trees: state.trees.slice(0, removeFromIndex)
      }
    },
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:12,代码来源:reducer.ts

示例5: catch

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

  const jsonFields = R.filter(R.pathEq(['options', 'json'], 'str'))(fields);
  if (R.not(R.isEmpty(jsonFields))) {
    logger.debug(TAG, { jsonFields });

    const toJson = value => {
      if (R.is(String, value) && value.length) {
        try {
          return JSON.parse(value);
        } catch (e) {
          logger.warn(TAG, e, { jsonFields });
          return null;
        }
      }
      if (R.is(Object, value)) {
        return value;
      }
      return null;
    };

    const transformValue = R.over(R.lens(R.prop('value'), R.assoc('value')), toJson);
    const transformedFields = R.map(transformValue)(jsonFields);
    const wrappedFields = R.mergeDeepRight(fields, transformedFields);

    logger.log(TAG, 'wrappedFields', { wrappedFields });
    return { modelName, fields: wrappedFields };
  }

  return { modelName, fields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:39,代码来源:index.ts

示例6: isErrorResponse

export function isErrorResponse(error) {
  const isError = R.pathEq(['response', 'data', 'name'], 'Error')(error);
  const isAsuna = /^ASUNA__.+/.test(R.path(['response', 'data', 'code'])(error));
  return isError || isAsuna;
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:5,代码来源:error.ts

示例7: 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

示例8: pathEq

const isAdmin = (ctx): boolean => pathEq(['state', 'user', 'userData'], true, ctx);
开发者ID:benjambles,项目名称:my-own-world,代码行数:1,代码来源:is-admin.ts

示例9: openBookmarkTree

import * as R from 'ramda'
import {SagaIterator} from 'redux-saga'
import {all, call, put, select} from 'redux-saga/effects'
import {ActionType} from 'typesafe-actions'

import {BookmarkTree} from '../../../../types'
import {RootState} from '../../../rootReducer'
import * as bookmarkCreators from '../../actions'
import {getBookmarkTree} from '../utils/getters'

export const bookmarkTreesSelector = (state: RootState) => state.bookmark.trees
const treeIdEquals = R.pathEq(['parent', 'id'])

export function* openBookmarkTree({
  payload
}: ActionType<typeof bookmarkCreators.openBookmarkTree>): SagaIterator {
  try {
    const [trees, bookmarkTree]: [Array<BookmarkTree>, BookmarkTree] = yield all([
      select(bookmarkTreesSelector),
      call(getBookmarkTree, payload.id)
    ])

    // if tree is already in view, no need to re-render
    if (trees.some(treeIdEquals(payload.id))) return

    const parentIndex = trees.findIndex(treeIdEquals(payload.parentId))
    // if parent doesn't exist, do not show this tree in the view
    if (parentIndex < 0) return

    yield put(bookmarkCreators.setBookmarkTrees([...trees.slice(0, parentIndex + 1), bookmarkTree]))
  } catch (err) {
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:31,代码来源:openBookmarkTree.ts


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