當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。