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


TypeScript get.default函数代码示例

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


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

示例1: switch

export const searchReducer: ActionReducer<Object> = (state: ISearchState = defaultState, action: Action) => {
    const payload = action.payload;

    switch (action.type) {
        case types.REQUEST: {
            const { searchTerm, itemType, reset = false } = payload;
            const key = getKey(itemType, searchTerm);

            return {
                ...state,
                [key]: {
                    ...(state[key] || defaultItem),
                    submitting: true,
                    loadedPage: reset ? 0 : _get(state, `[${key}].loadedPage`, 0)
                }
            }
        }

        case types.SUCCESS: {
            const { itemType, query, searchTerm, totalPages, list = [], loadedPage = 0, reset = false } = payload;
            const ids = list.map((item) => item.id);
            const key = getKey(itemType, searchTerm);

            return {
                ...state,
                [key]: {
                    ...(state[key] || defaultItem),
                    submitting: false,
                    error: false,
                    loadedPage,
                    totalPages,
                    perPage: query.per_page,
                    list: (reset || !state[key] ? defaultItem : state[key]).list.concat(ids)
                }
            };
        }

        case types.ERROR: {
            const { itemType, searchTerm } = payload;
            const key = getKey(itemType, searchTerm);

            return {
                ...state,
                [key]: {
                    ...state[key],
                    submitting: false,
                    error: true,
                }
            }
        }

        case CLEAN_CACHE: {
            return defaultState;
        }

        default:
            return state;
    }
}
开发者ID:pinkasey,项目名称:activegan,代码行数:59,代码来源:search.ts

示例2: reduce

export default function reduce(state: State = {} as State, action: any) {
	return {
		dirtyHandlerIds: dirtyHandlerIds(state.dirtyHandlerIds, {
			type: action.type,
			payload: {
				...action.payload,
				prevTargetIds: get(state, 'dragOperation.targetIds', []),
			},
		}),
		dragOffset: dragOffset(state.dragOffset, action),
		refCount: refCount(state.refCount, action),
		dragOperation: dragOperation(state.dragOperation, action),
		stateId: stateId(state.stateId),
	}
}
开发者ID:chenermeng,项目名称:react-dnd,代码行数:15,代码来源:index.ts

示例3: getAggregations

 getAggregations(path, defaultValue){
   const results = this.getResults()
   const getPath = ['aggregations',...path]
   return get(results, getPath, defaultValue)
 }
开发者ID:Baltox,项目名称:searchkit,代码行数:5,代码来源:Accessor.ts

示例4: Error

    mergeData.forEach((entity: any) => {
      const key = get(entity, keyPath);
      if (!key) {
        throw new Error(`Invalid key property with path "${keyPath}" in entitiesUtils::mergeEntitiesBy()`);
      }

      result[key] = iteratee(source[key], entity);
    });
开发者ID:dmikheev,项目名称:js-test-social-network,代码行数:8,代码来源:entitiesUtils.ts

示例5: resolveRef

function resolveRef(
  id: string,
  schema: object,
  options: Options
): InstantiateResult {
  const withoutRef = omit(schema, '$ref');

  const { schemaId = id, path } = parseRef(schema['$ref']);
  const validateFunction = options.ajv.getSchema(schemaId);

  if (!validateFunction) {
    return { hasResult: false, error: options.ajv.errors };
  }

  const resolved = get(
    validateFunction.schema,
    path.filter(p => p !== undefined),
    {}
  );
  const result = merge({}, resolved, withoutRef);

  return recursiveInstantiate(schemaId, result, options);
}
开发者ID:alexkuz,项目名称:json-schema-default-instance,代码行数:23,代码来源:instantiator.ts

示例6: jsonParse

export const csvParse = (csvContent, options) => {
  const { hasCategory } = options

  const mergeRows = (acc, { question, answer, answer2, category, action }) => {
    const [prevRow] = acc.slice(-1)
    const isSameAnswer = prevRow && (prevRow.answer === answer && (!answer2 || answer2 === prevRow.answer2))
    if (isSameAnswer) {
      return [...acc.slice(0, acc.length - 1), { ...prevRow, questions: [...prevRow.questions, question] }]
    }
    const categoryWrapper = hasCategory ? { category } : {}
    return [...acc, { answer, answer2, action, ...categoryWrapper, questions: [question] }]
  }
  const categoryWrapper = hasCategory ? ['category'] : []
  const rows = parseCsvToJson(csvContent, {
    columns: ['question', 'action', 'answer', 'answer2', ...categoryWrapper]
  }).reduce(mergeRows, [])

  // We trim the header if detected in the first row
  if (get(rows, '0.action') === 'action') {
    rows.splice(0, 1)
  }

  return jsonParse(rows, options)
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:24,代码来源:parsers.ts

示例7: get

 getSuggestion(){
   return get(this.searchkit.getSuggestions(), [0,"options", 0, "text"], false)
 }
开发者ID:Baltox,项目名称:searchkit,代码行数:3,代码来源:SuggestionsAccessor.ts

示例8: Error

 constructor(fieldOptions){
   super(fieldOptions)
   if(!get(this.fieldOptions, "options.childType")){
     throw new Error("fieldOptions type:children requires options.childType")
   }
 }
开发者ID:Nostres,项目名称:searchkit-redux,代码行数:6,代码来源:ChildrenFieldContext.ts

示例9:

 (listState: any, item = {}, itemsToDisplay) =>
   _take(_get(listState, 'list', []), itemsToDisplay).map(id => item[id])));
开发者ID:pinkasey,项目名称:activegan,代码行数:2,代码来源:list.ts


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